"Angularjs add item list append!"
Bootstrap 3.0.0 Snippet by muhittinbudak

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> <div class="container" ng-app="myShoppingList" ng-cloak ng-controller="myCtrl" > <div class="row"> <div class="well text-left"> <div class="well" style="background-color:yellow;"><h3>Angularjs is very easy! try!</h3></div> <ul class="list-group" > <li ng-repeat="x in products" class="list-group-item" data-value="1">{{x}}<span class="glyphicon glyphicon-remove pull-right" ng-click="removeItem($index)" style="cursor:pointer;" ></span></li> </ul> <div class="row"> <div class="col-md-12 form-group"> <input type="text" class="form-control" placeholder="text add(ekleyin)" ng-model="addMe" > <button style="margin-top: 10px;" ng-click="addItem()" class="btn btn-primary btn-block">Add</button> </div> </div> <p class="well col-md-12 " ><b>{{errortext}}</b></p> </div> </div> </div>
var app = angular.module("myShoppingList", []); app.controller("myCtrl", function($scope) { $scope.products = ["Süt", "Çay", "Kek", "Domates", "Patatos"]; $scope.addItem = function () { $scope.errortext = ""; if (!$scope.addMe) {return;} if ($scope.products.indexOf($scope.addMe) == -1) { $scope.products.push($scope.addMe); } else { $scope.errortext = "The item is already in your shopping list.(Aynısını zaten eklemişsin)"; } } $scope.removeItem = function (x) { $scope.errortext = ""; $scope.products.splice(x, 1); } });

Questions / Comments:

Related: See More