javascript - how to add row dynamically in angular .js on button click? -


I am creating a list view in angular.js when I get static data, I am able to create a list. . I need to speed up in other words when I need to make a row on the user click button. I need to create a list of the same text examples ("list"), but separate ID ("0", "1", "2"). ..ETC). Is it possible to prepare a list? .. here I am trying to do ..

   & Lt; Script src = "// netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script> & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; JS bin & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Button type = "button" class = "btn btn-primary" & gt; Primary & lt; / Button & gt; & Lt; Ul ng-controller = "list controller" & gt; & Lt; Li & gt; & Lt; One ng-click = & gt; & Lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

JS Code:

  var myApp = angular.module ('myApp', []); MyApp.controller ('ListController', Function ($ Range)) {Warning ('-')]);  

You add new objects into the data model by pushing them into your data array. Content: 'content1'}, {name: 'item2', content: 'content2'}, {name: 'item3', ' , / P>

  $ scope.items = [{content: 'content3'}]; / * Html / $ scope.activeItem = {Name: '', Content: ''} $ scope.addItem = function () {$ scope.items.push ($$) to `ng-model` of 2 inputs Bind it to. Scope.activeItem); $ Scope.activeItem = {} / * Reactivated item * /}  

In HTML use

  & lt; Button ng-click = "addItem ()" & gt; Add & lt; / Button & gt;  


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -