Code Download: Https://files.cnblogs.com/files/xiandedanteng/angularjsCtrl.rar
Code:
<!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd "><HTMLNg-app= "Notesapp"> <Head> <title>New Document</title> <MetaCharSet= "Utf-8"> <Scriptsrc= "Angular1.4.6.min.js"></Script> </Head> <BodyNg-controller= "Mainctrl as CTRL"> <H1>{{ctrl.msg}} AngularJS</H1> <ButtonNg-click= "ctrl.changemsg ()">Cg</Button> </Body></HTML><Scripttype= "Text/javascript"><!--Angular.module ('Notesapp', []). Controller ('Mainctrl',[function(){ var Self= This; Self.msg='Hello'; Self.changemsg=function(){ if(self.msg=='Hello') {self.msg='Goodbye'; }Else{self.msg='Hello'; } }; }]);// -</Script>
Click the button before and after the effect:
Points:
Any variables defined on the controller instance are accessible and can be presented to the user in HTML. In most cases, the data can be displayed in the UI in this way.
Example of ANGULARJS Controller