Use of Angularjs Ui-router

Source: Internet
Author: User

<div data-ui-view= "" ></div>

The Data-ui-view here will take

<div ui-view= ""/> The ui-view directive tells $state where to place your templates, you can add name,autoscroll,onload attribute so f Yi.html this is a generic template, to figure out a few names: State,view

For example, there is a state: named Selectedproject, the Templateurl is "selectedproject.html" and then in selectedproject.html ask Price has <div ui-view= ""/             And there are some other parts of the public content that we want to act as selectedproject child templates. State ("Selectedproject.reportlist", {url: "/reportlist", Templateurl: "Reportlist.html", Controller: ' Totalpage '}) such as State:selectedProject.reportList, because A parent-child relationship is formed on the name, so it takes its own template to render the Ui-view part of the parent template.

Therefore, once you want to extract some common parts out, this is a way, the disadvantage is that it to extract a parent state out, so that there will be a state and corresponding template and controller

Question one: So, what if we want to include a common.html in? We don't want to extract the first parent state, because all the sub-routes have changed. Answer: Add the contents of the common section directly to the parent template

Question two: The URL of the child state is written relative to the URL of the parent state, so if the go address is a child state, how do you set the parameter values in the parent state?

The value of href VS ui-sref:ui-sref can be the name of any state of config, and can be used relative to the state name, and can be followed with the value of the parameter, so the combination of ui-router is easy to use Eg:<a Ui-sref= "Contacts.detail ({id:contact.id})" >{{contact.name}}</a>

href is a generic jump link, but does not recognize the custom state name

Use of Angularjs Ui-router

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.