angularjs - Angular Directive Two-Way Binding Issue -
I am making a custom input directive for some additional features.
app.directive ('MyTextInput', [function] {var Directive = {}} Directive. RTE = 'A'; Director.Squipe = {TextualDom: '='}; Directive .link = function ($ scope, element, etter) {/ FUnctionality}; directive.template = '& lt; input ng-model = "text mode" type = "text" & gt;'; return instructions;}] );
And using separate scope property textModel
for binding in two ways. And the parent area is HTML:
Variables in the control area $ scope.myScopeVariable = "";
is defined.
When I do this The directive input that is typed in & lt; Span & gt;
is able to print in the tag. It shows that it is updating.
The problem is.
In the field of parents. I have a method that will be executed on a button click.
$ scope.do Some = function () {console.log ($ scope.myScopeVariable); }; Click the button
The log is empty which is supposed to be typed into the instructional input.
This is the strength
Now define the radius variable
$ scope.myScopeVariable = {key: '};
and
& lt; Div my-text-input text-model = "myScopeVariable.key" & gt; & Lt; / Div & gt; Use as HTML in & Lt; Span & gt; TYPED: {{myScopeVariable.key}} & lt; / Span & gt;
So it's working everywhere even in the first function called doSomething ()
.
Any thoughts that are happening here?
This is because myScopeVariable
is written to string As the value happens.
So if you change the value of the textbox of the directive, it will not be reflected.
And in the second method, you are referring to the object. Therefore whenever you change the value of the object, its relevant clock method is called. And the value will be updated.
Comments
Post a Comment