<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <Scripttype= "Text/javascript"src= "Js/angular.min.js"></Script>//introduction of Angular JS </Head> <Body> <DivNg-app= "MYAPP"Ng-controller= "Myctrl"> <inputtype= "text"Ng-model= "Name" /><BR/> <ButtonNg-click= "Toggle ()">Point Me</Button> </Div> <Scripttype= "Text/javascript"> varapp=Angular.module ("myApp",[]); App.controller ('Myctrl',function($scope) {$scope. Toggle=function() {alert ($scope. Name); } }) </Script> </Body></HTML>
Click event to add parentheses
<button ng-click= "can be arbitrarily named ()" > Point me </button>
When you get the value, add $scope $scope must be added and cannot be changed
Alert ($scope. Name);
Dynamic Append
<!DOCTYPE HTML><HTML> <Head> <MetaCharSet= "UTF-8"> <title></title> <Scripttype= "Text/javascript"src= "Js/angular.min.js"> </Script> </Head> <Body> <DivNg-app= "MYAPP"Ng-controller= "Namesctrl"> <inputtype= "text"Ng-model= ' name '/><BR/> <inputtype= "text"Ng-model= ' d '/><BR/> <ButtonNg-click= "DJ ()">Add to</Button> <ul> <binng-repeat= "x in List">{{x.name+ ', ' +x.title}}</Li> </ul> </Div> <Scripttype= "Text/javascript">Angular.module ("myApp", []). Controller ('Namesctrl',function($scope) {$scope. List=[{name:'HTML', Title:'HTML5'}, {name:'CSS', Title:'CSS3'}, {name:'JS', Title:'jquery'} ]; $scope. DJ=function(){ varI={name: $scope. Name, title: $scope. D}; $scope. List.push (i); }; }); </Script> </Body></HTML>
ANGULARJS Click events and Dynamic Append