(3)
Use routing and $ location to switch views
App. JS:
Angular. Module ('shop ',
[
'Ignore ',
'Ngresource ',
'Shop. controllers ',
'Shop. service ',
'Shop. filter'])
. Config ([
'$ Routeprovider ',
'$ Locationprovider ',
'$ Interpolateprovider ',
Function ($ routeprovider,
$ Locationprovider,
$ Interpolateprovider ){
$ Routeprovider
. When ('/home', {Controller: XXX, templateurl: XXX. tmpl })
. When ('/home', {Controller: XXX, templateurl: XXX. tmpl })
. When ('/home', {Controller: XXX, templateurl: XXX. tmpl })
. Otherwise ({redirectto: '/000000 '});
}
]);
Use commands to modify the DOM
Angular. Module ('shop. ctive Ve', [])
. Directive ('ngbkfocal ', functive (){
Return {
Link: function (scope, element, attrs, Controller ){
// Returns the external scope reference. The Dom element that exists is passed to the attribute array of the instruction and the Controller on the DOM element.
Element [0]. Focus ();
// Call the focus Method of the DOM Element
}
}
});
Twig:
<Button ngbk-focus> if no error is found, I am focused. </button>
Form Verification:
<Form name = "userform">
Email <input type = "email" NG-module = "user. Email" required>
Age <input type = "Number" NG-modlue = "user. Age" NG-maxlength = '3' ng-minlength = '1'>
<Button> submit </button>
</Form>
This section uses HTML5 attributes in HTML. Angular will adapt to the old-fashioned browser to implement the same function.
Add ng-controller = "usercontroller" NG-submit = "onsubmit ()" to the form tag ()"
In the browser, you can get the Form validation status through $ valid, so you can click the button or not.
Add ng-Disabled = "! Userform. $ valid"
The first two chapters are over, and now there are 48 pages.