Usage and configuration of route in Angularjs _angularjs

Source: Internet
Author: User

Angular is a single page application framework developed by Google and is one of the more mainstream one-page application frameworks. The powerful place has many, such as two-way data binding, applying the back-end MVC pattern to the front end, custom directives, and so on.

Since it is a single page application, it is definitely inseparable from the page switch. Let's start with the angular route.

Angular to achieve page switching using the route.

<script src= "Js/plugins/angular/angular.min.js" ></script>

Angular.min.js to be loaded before angular-ui-router.min.js. And then we're going to sign up in app.

(function () {
angular.module (' demo ', [
' Ui.router ', 
])

After registration, you need to configure route.

function config ($stateProvider, $urlRouterProvider, $httpProvider) {
$urlRouterProvider. Otherwise ("/home/get") ;
$stateProvider
. State (' login ', {
URL: "/login",
templateurl: "). /views/login.html ",
})
. State (' home ', {
abstract:true,
URL:"/home ",
templateurl:" views/ Common/content.html ",
})
. State (' Home.get ', {
URL:"/get ",
templateurl:" Views/get.html ",
data: {pagetitle: ' Example View '}
}
. State (' Home.post ', {
URL: "/post",
templateurl: "views/post.html",
data: {pagetitle: ' Example View '}< c21/>});
App = Angular.module (' demo ');

Configuration is over here. Each State in the configuration is a view that represents a page, the page jumps with state, and the corresponding HTML file is in the templateurl corresponding file.

The above is a small set to share the ANGULARJS in the use of route and configuration of the relevant knowledge, hope to help you.

Related Article

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.