AngularJS views View

Source: Internet
Author: User

ANGULARJS supports single-page applications through multiple views on a single page. To do this angularjs provides Ng-view and ng-template instructions, as well as $routeProvider services.

Ng-view

Open view, just a placeholder, no value example:<div ng-view></div>

Ng-template

Create a view, with the script tag, type ng-template, containing an id attribute for the $routeprovider mapping control, ID pointing to an HTML page

$routeProvider

The configuration of the main URL is a angular object that maps them to the appropriate HTML page or ng-template

Use

var app = Angular.module ("app", [' Ngroute ']);        App. Config ([' $routeProvider ',         function ($routeProvider) {            $routeProvider.               When ('/addstudent ', {                  templateurl: ' addstudent.html ',                  controller: ' Addstudentcontroller '               }).               When ('/viewstudents ', {                  templateurl: ' viewstudents.html ',                  controller: ' Viewstudentscontroller '               }).               Otherwise ({                  redirectto: '/addstudent '               );         }]);

Config is configured, the configuration item is an array, the parameter of the callback function is $routeprovider, the $routeprovider when method is used, parameter 1 is the request path, and parameter 2 is the object

Contains Templateurl to the controller for the view, otherwise to the default view, and if the page does not exist, the render view can be used as Template: (Label + content)

 

AngularJS views View

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.