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

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <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); } });

Related: See More


Questions / Comments: