javascript - Binding text inputs to a directives attribute -
I am trying to force a text input to an attribute within an instruction, the reason is that I do not want every time I add a new instruction like this, to present the controller. Is it also possible or do you always have to specify the controller while using the NG-model. Example of code is equal to thousand words, please take a look. As you type input, the amount should be changed.
There are two problems with your code:
-
< code> scope $ Watch (attrs.amount, function (v) {...}); & lt; = & Gt;
scope $ watch ('100', function (v) {...});
Whoever is not going to change, does not do what you want.Since element attribute will never change,
function draw (anime) {var zodiac = etter.mount; Not very useful.
You can fix them like this:
area. $ watch ('zodiac', function (v) {...});
and
function draw (anime) {var zodiac = scope.mount; ...
Also see .
If you need to set up two-way data-binding in the field of parent, and to force the property to be specified in the parent area . Ex:
// $ scope.someAmount = 100 of parental scope; // in HTML & lt; custommarc zodiac = "someAmount" ... // In the Director area: {amount: '=' ...
Comments
Post a Comment