Angular Application | angularjs w3c
ItistimetocreatearealAngularJSApplication.MakeaShoppingListLetsusesomeoftheAngularJSfeaturestomakeashoppinglist,whereyoucanaddorremoveitems:ApplicationExplainedStep1.GettingStarted:StartbymakinganapplicationcalledmyShoppingList,andaddacontrollernamedmyCtrltoit.Thecontrolleraddsanarraynamedproductstothecurrent$scope.IntheHTML,weusetheng-repeatdirectivetodisplayalistusingtheitemsinthearray.ExampleSofarwehavemadeanHTMLlistbasedontheitemsofanarray:
It is time to create a real AngularJS Application.
Make a Shopping ListLets use some of the AngularJS features to make a shopping list, where you can add or remove items:
Application Explained Step 1. Getting Started:Start by making an application called myShoppingList, and add a controller named myCtrl to it.
The controller adds an array named products to the current $scope.
In the HTML, we use the ng-repeat directive to display a list using the items in the array.
ExampleSo far we have made an HTML list based on the items of an array:
<script>
var app = angular.module("myShoppingList", []); app.controller("myCtrl", function($scope) { $scope.products = ["Milk", "Bread", "Cheese"];});
<div ng-app="myShoppingList" ng-controller="myCtrl"> <ul> <li ng-repeat="x in products">{{x}}</li> </ul></div>
Try it Yo...