Angular Reading Notes (3)

Source: Internet
Author: User

(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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.