How do I access UI component in Typescript - ionic

Moderator: Support

maithili
Posts: 10
Joined: Tue Nov 24, 2020 12:36 pm

How do I access UI component in Typescript - ionic

Post by maithili »

Hi,
I want to change a component from Disabled to enabled on a button click
In the button click how to get access to the component.
getElementById does not work
There seems to be references to $scope variable in documentation but that is not reconised (Cannot find name '$scope')
Then there is reperecents of Appery.io() but that also is does not work.

How do you access UI components/get handle to it?

Thanks

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: How do I access UI component in Typescript - ionic

Post by Serhii Kulibaba »

Hello,

What Ionic version do you use here Ionic 1 or Ionic 4?

maithili
Posts: 10
Joined: Tue Nov 24, 2020 12:36 pm

Re: How do I access UI component in Typescript - ionic

Post by maithili »

ionic 4

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: How do I access UI component in Typescript - ionic

Post by Serhii Kulibaba »

Please use the property

Code: Select all

[attr.disabled]

for that. You can use any boolean variable or expression here to disable/enable component

maithili
Posts: 10
Joined: Tue Nov 24, 2020 12:36 pm

Re: How do I access UI component in Typescript - ionic

Post by maithili »

Hi,
So sorry.. did not quite understand your reply
[attr.disabled]??

If i have a button or input component.. how do I use this
say SubmitButton1

SubmitButton1[attr.disabled] =false.. or something like that??? That does not seem to work

The componentname is not getting recognised. How can I get handle to compoenent so I can change its attributes/value.

i also tired variations of this.Apperyio.get() but that does not work..
I could not find any documentation for this.Apperyio

So sorry if this a very simple and obvious thing. i am not able to resolve it

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: How do I access UI component in Typescript - ionic

Post by Serhii Kulibaba »

Please add it to the "Properties" panel of the component you want to disable/enable:

Screenshot_35.png
Screenshot_35.png (67.09 KiB) Viewed 1599 times

If you need to control it with the TypeScript - please use a variable instead of the simple Boolean value as you can see on the screenshot abow

ahmethelal009
Posts: 2
Joined: Sat Aug 21, 2021 7:46 am

Re: How do I access UI component in Typescript - ionic

Post by ahmethelal009 »

How do I Disable a Button Called "StartAgain" (=Component Name) whit type Script?(IONIC 5)

this .StartAgain.disabeld = true?

ahmethelal009
Posts: 2
Joined: Sat Aug 21, 2021 7:46 am

Re: How do I access UI component in Typescript - ionic

Post by ahmethelal009 »

I want also to disable a IONIC 5 Button.
I have added
[attr.disabled] with value to to the parameters of the IONIC5 button,

What will be the type script if I want disable or enable the Button called StartAgain (As COMPONENT NAME) .

What about this code: Will this code work?

this.StartAgain.attr.dsisabled=true??????

Serhii Kulibaba
Posts: 147
Joined: Tue Aug 27, 2013 1:47 pm

Re: How do I access UI component in Typescript - ionic

Post by Serhii Kulibaba »

It is not possible to use the component name to disable/enable the component. Please use only its property disabled as I shown above

Post Reply