I am new to AngularJS. For a long time I tried to abuse it the way I always used the Javascript-Framework, such as JQuery or Mootools. Now I realized that this will no longer work ... But I ran into some big problems since I always create my HTML output using CMS.
So, this is pretty static when it first appears ... A small example:
<ul> <li>foo <span>delete</span></li> <li>bar <span>delete</span></li> <li>blub <span>delete</span></li> </ul>
Now I thought that two-way data binding means that I can generate a view using Angular Scope and Controller, but it can also generate models from a view.
I can confuse something there ... So here is my question. Is there a way to trigger models from static HTML output from CMS?
I tried something like this ...
<ul ng-controller="Ctrl"> <li ng-init="item[0].name=foo">{{item[0].name}} <span ng-click="remove(0)">delete</span></li> <li ng-init="item[1].name=bar">{{item[1].name}} <span ng-click="remove(1)">delete</span></li> <li ng-init="item[2].name=blub">{{item[2].name}} <span ng-click="remove(2)">delete</span></li> </ul>
And in my controller, I wrote a delete function. But when he deleted, he deleted only the name ... the span button was still
This really worked when I defined my data as a javascript array and made all the output through Angular with ng-repeat ... like this:
<ul ng-repeat="it in item"> <li>{{it.name}} <span ng-click="remove($index)">delete</span></li> </ul>
Hope I did something here and everyone got my problems and problems? Can someone tell me if it is possible what I'm trying to do?
source share