TextView's `editable` property doesn't bind
Using the normal editable property works
<TextView editable="false" [(ngModel)]="textData"></TextView>
But using the angular's binding doesn't work
<TextView [editable]="false" [(ngModel)]="textData"></TextView>
<TextView [editable]="'false'" [(ngModel)]="textData"></TextView>
@Jai-Krish binding to editable should work as expected - demonstration in this text applicaiton and also here. Note that when binding you should have a boolean property and not passing directly the value (false in your example). As you can not have a property called false in JS I am suspecting that you need to declare a boolean property in your component class (e.g. something like editState or isEditable) and use to for your binding.
If you still experience troubles with binding to editable, then please share the code you are using and also details on which platform and which API level the issue occurs.
@NickIliev it was my bad, I've binded the component with an undefined object of an array which is yet to be populated. This broke the whole component and the condition inside the editable property didn't parse it seems. I don't want to use *ngIf and totally hide the component, I just want it to be disabled if the binding object is not available. Is there any way to do that?
Thank you for your time.
@Jai-Krish perhaps you can create a condition which updates the editable property depending on whether the context has arrived or not. For example, you said that you are expecting an array of objects - initialize an empty array as default value and change your editState boolean depending on the array length (using observables like RxObservable)
For example if [this is our Rx Observable array of objects](import { Observable as RxObservable } from "rxjs/Observable";) you can create your editState boolean with initial false value like
public editState: boolean = false;
and in your XML file introduce the binded editState
<TextView row="0" hint="edit text" text="" [editable]="editState"></TextView>
Now the last thing we need is to update the value of editState to true when needed. In this specific example, we are simulating an API call which is returning asynchronously our array objects so I can change the value during the mock.
let intervalId = setInterval(() => {
counter++;
if (counter == 6) {
console.log("text view is now editable!");
this.editState = true;
}
items.push(new DataItem(counter + 1, "data item " + (counter + 1)));
subscr.next(items);
}, 1000);
With this example, the text view will be non-editable at first and only after the counter of items hits 6 it will become editable. Of course. this is only one possible scenario- you can adjust the logic for your needs using either observables or structural directives
@NickIliev thank you for the code samples but my scenario is quiet different maybe this minimal sample project could help TextViewBlur.zip
You can use ternary operation inside your binding
<TextView [editable]="{{ allMedia.length > 0 ? true : false }}">