如何從一個單一的輸入字段分別改變附加文本名稱.. https://jsbin.com/lihamizuta/edit?html,js,output < - 在這裏點擊我jsbin一次.. 我在這事件完全混亂,任何人可以請幫助我..angularjs變化附加文本每名
var app = angular.module('myapp', ['ngSanitize']);
app.controller('AddCtrl', function ($scope, $compile) {
$scope.field = {single: 'untitled'};
$scope.addNew_SingleField = function (index) {
var singlehtml = '<fieldset id="single_field" ng-click="selectSingle($index)">//click me once// <label ng-bind-html="field.single"></label> <input type="text" placeholder="Enter name"><button ng-click="removeSingle($index)">-</button></fieldset>';
var single = $compile(singlehtml)($scope);
angular.element(document.getElementById('drop')).append(single);
};
$scope.removeSingle = function (index) {
var myEl = angular.element(document.querySelector('#single_field'));
myEl.remove();
};
$scope.selectSingle = function (index) {
$scope.showSingle_Fieldsettings = true;
};
});
<!DOCTYPE html>
<html ng-app="myapp">
<head>
\t <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0-beta.2/angular.min.js"></script>
\t <script src="https://code.angularjs.org/1.5.0-rc.0/angular-sanitize.min.js"></script>
</head>
<body ng-controller="AddCtrl">
\t <button ng-click="addNew_SingleField($index)">Click me again</button>
\t <div id="drop"></div>
\t <form ng-show="showSingle_Fieldsettings">
\t \t <div class="form-group">
\t \t \t <label>Field Label name change here (?)</label>
\t \t \t <br/>
\t \t \t <input ng-model="field.single" class="fieldLabel">
\t \t </div>
\t </form>
</body>
</html>
請解釋一下你想要做什麼? – micronyks
如果我們點擊字段將如下圖所示,如果我們點擊提交標籤選項,將顯示的字段的任何地方按鈕多次,,,我想從單一的顯示字段標籤輸入選項seperately改變「無題」的標籤名稱..請幫我 –