Hello everybody! how can we add fields Dynamically in Angularjs I have an exemple but it doesn't work when i want to add <div> into another <div> ----------------------------------------
<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script> <script type="text/javascript" src="js/app.js"></script> <script type="text/javascript" src="js/plugins/jquery/jquery.min.js"></script> <script type="text/javascript" src="js/plugins/jquery/jquery-ui.min.js"></script> <script type="text/javascript" src="js/plugins/bootstrap/bootstrap.min.js"></script> </head> <body ng-app="Webapp" ng-controller="WebCtrl"> <h1>Module Opale</h1> Titre<input type="text" placeholder="Titre"><br /> Metadonnées<input type="text" placeholder="Titre"><br /> Objectif du module <input type="text" placeholder="Objectif"> <div class="form-group" data-ng-repeat="division in divisions"> <h2><a ng-show="showAddDivision(division)" ng-click="addNewDivision()">*</a>Division</h2> Titre<input type="text" placeholder="Titre"><br /> Titre court<input type="text" placeholder="Titre"><br /> <div class="form-group" data-ng-repeat="grainContenu in grainContenus"> <h3><a ng-show="showAddGrainContenu(grainContenu)" ng-click="addNewGrainContenu()">*</a>Grain de Contenu</h3> Titre<input type="text" placeholder="Titre"><br /> Titre court<input type="text" placeholder="Titre"><br /> <h4>Information</h4> Titre<input type="text" placeholder="Titre"><br /> <textarea rows="4" cols="50"></textarea><br /> </div> </div> </body> </html> ------------------------ angular.module("Webapp",[]) .controller("WebCtrl",function($scope){ //new division $scope.divisions = [{id: 'division1'}]; $scope.addNewDivision = function() { var newItemNo = $scope.divisions.length+1; $scope.divisions.push({'id':'division'+newItemNo}); }; $scope.showAddDivision = function(division) { return division.id === $scope.divisions[$scope.divisions.length-1].id; }; //new grainContenu $scope.grainContenus = [{id: 'grainContenu1'}]; $scope.addNewGrainContenu = function() { var newItemNo = $scope.grainContenus.length+1; $scope.grainContenus.push({'id':'grainContenu'+newItemNo}); }; $scope.showAddGrainContenu = function(grainContenu) { return grainContenu.id === $scope.grainContenus[$scope.grainContenus.length-1].id; }; }); -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/d/optout.
