angular.js is great for complex JavaScript-based web client applications, but I'm also thinking of using it for small, simple JavaScript tasks.
For example, I have a list with some elements:
<ul> <li data-id="1">Foo</li> <li data-id="2">Bar</li> </ul>
Now I want to add some buttons in the HTML that should filter and / or sort the list after some user input, which should be an easy task.
Is there a way to extract data from existing HTML elements to use with angular.js? The data must be in HTML, so the search engine could also get information that
Edit for clarity:
The end result is that the data from the ul list will be transferred to the model of the controller that processes the list. ( [{id:1, text:"Foo"}, {id:2, text:"Bar"}] )
If I push more objects to the model, the list should display them.
If I applied a filter to the model, it should filter out the li elements.
A better scenario would be similar to this:
<div ng-model="data"> <ul ng-repeat="object in data | filter:filterCriteria"> <li data-id="1">Foo</li> <li data-id="2">Bar</li> <li data-id="{{object.id}}">{{object.text}}</li> </ul> </div>
source share