how to use ng-repeat in append to get the key value?
<p>if i use ng-repeat in append html div, the content is not appending. how to get the label name key value on appended each fields. i want to change each label name from field label options from below code. click on appended div, it will shows filed label options, from there i have to change each label name seperately.. pls help me</p><div class="snippet" data-lang="js" data-hide="false"><div class="snippet-code"><pre class="snippet-code-js lang-js prettyprint-override"><br /><code>var app = angular.module('myapp', ['ngSanitize']);<br /><br />app.controller('AddCtrl', function ($scope, $compile) {<br /><br /> $scope.field = {single: 'untitled'};<br /> $scope.addNew_SingleField = function (index) {<br /> var singlehtml = '<fieldset ng-repeat="(fieldkey, field) in singleField" ng-click="selectSingle($field)"><label ng-bind-html="field.single"></label><input type="text" placeholder="Enter name" name="{{field.single}}"><button ng-click="removeSingle($index)">-</button></fieldset>';<br /> var single = $compile(singlehtml)($scope);<br /> angular.element(document.getElementById('drop')).append(single);<br /> };<br /> $scope.removeSingle = function (index) {<br /> var myEl = angular.element(document.querySelector('#single_field'));<br /> myEl.remove();<br /> };<br /> $scope.selectSingle = function (field) {<br /> selectedField = field<br /> $scope.showSingle_Fieldsettings = true;<br /> };<br />});</code><br /></pre><pre class="snippet-code-html lang-html prettyprint-override"><br /><code><!DOCTYPE html><br /><html ng-app="myapp"><br /><br /><head><br /> <script src="http://ift.tt/1YHObKi"></script><br /> <script src="http://ift.tt/1mFkDBk"></script><br /></head><br /><br /><body ng-controller="AddCtrl"><br /> <button ng-click="addNew_SingleField($index)">Single Line Text</button><br /> <div id="drop"></div><br /><br /> <form ng-show="showSingle_Fieldsettings"><br /> <div class="form-group"><br /> <label>Field Label(?)</label><br /> <br/><br /> <input ng-model="selectedField.single" class="fieldLabel"><br /> </div><br /> </form><br /><br /></body><br /><br /></html></code><br /></pre></div></div><br /><h2>Click here view more answers <a href="%20http://stackoverflow.com/questions/34470442/how-to-use-ng-repeat-in-append-to-get-the-key-value">http://ift.tt/1YHO95a</a></h2>
Nhận xét
Đăng nhận xét