I am new to angular and trying to create my first directive.
Here is an example:
isrcorderapp.directive "isrcrow", () ->
restrict:'A'
controller: 'isrcorders'
template: '<td><input id="artist" ng-model="{{artist}}"/></td>
<td><input id="title" ng-model="{{title}}"/></td>
<td><select id="isrctype" ng-model="{{isrctype}}" ng-options="s.type for s in recordingTypes" class="ng-pristine ng-valid"></select></td>
<td><input id="duration" ng-model="{{duration}}"/></td>
<td><input id="year" ng-model={{year}}/></td>
<td><input type="button" value="Add ISRC" ng-click="AddIsrc()" class="btn btn-small btn-success" />
<input type="button" value="Delete" ng-click="RemoveIsrc()" class="btn btn-small btn-danger" />
</td>'
replace: false
scope:
artist:'@'
title:'@'
isrctype:'@'
duration:'@'
year:'@'
link: (scope,element,attr) ->
This directive was working until I added the scope and ng-model in the elements.
Here is a working example before the additions were made:
http://plnkr.co/edit/oxXZlsFIDAbBCYMDOYMH?p=preview
I would like to add the values of the fields(artist.title,isrcType...)
to the scope object but I keep getting errors when the web page is loaded:
Error: [$parse:syntax]
How can I fix this? What am I doing wrong here?