我想要做的是使用角度將每個用戶輸入轉換爲標籤。我相信我做了正確的事情,但沒有成功。如果有人看一下這段代碼,我會很感激。謝謝使用angular.js將用戶輸入轉換爲標籤
這裏是一個plunker
<div class="row" ng-controller="tagForm">
<div ng-click="addEntry()">
<div class="col-xs-12 col-sm-12 col-md-10 ">
<input type="text" placeholder="What are your area of expertise" ng-model="newEntry.name" class="form-control border" />
</div>
<div class="col-xs-12 col-md-2 center form-button">
<input type="button" value="Add" class="btn btn-orange btn-add" />
</div>
<div class="col-md-8 col-sm-offset-2" id="up">
<br />
<span class="label label-primary" ng-repeat="entry in entries">{{entry.name}}</span>
</div>
</div>
</div>
app.controller('tagForm', ['$scope', function($scope) {
return $scope.addEntry = function() {
$scope.entries.push($scope.newEntry);
return $scope.newEntry = {};
};
}]);
請問你能解釋一下嗎?即你想將每個轉換爲標籤? – BlaShadow 2014-09-04 16:41:01
我試圖做的是,當用戶在輸入框中鍵入一個單詞並單擊添加時,它會將該單詞轉換爲標籤。像這樣的http://aehlke.github.io/tag-it/ – 2014-09-04 17:07:03