Answer the question
In order to leave comments, you need to log in
Why is the model passing in angular.js not parsed?
A simple example: I create my own directive, in the template of which there is a simple input.
In order to use the directive repeatedly (as a component), I want to bind it each time to a different model when using it.
I do something like this <form ng-controller="ForTosterCtrl as tosterCtrl">
...
<my-directive icon="home" placeholder="Начало" model="tosterCtrl.startPoint"></my-directive>
scope: {
icon: '@',
placeholder: '@',
model: '='
}
<input ng-model="{{model}}" placeholder="{{placeholder}}"/>
Syntax Error: Token '{' invalid key at column 2 of the expression [{{model}}] starting at [{model}}].
Answer the question
In order to leave comments, you need to log in
well, because such syntax is forbidden for expressions. Read the documentation. ng-model uses two-way binding, so the parentheses (sugar for value interpolation) need to be removed.
ps I highly recommend reading the documentation for the tools you use. Well, or at least take video courses.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question