Specific usage:
<a ui-sref= "man" > Men </a>
This is a very simple ui-sref use, when JavaScript regenerates a page, it looks for the state in $state named "Man", reads the URL of the state, and then generates href= "url" in the A tag.
The results are as follows: <a ui-sref= "man" href= "#/man.html" > Men </a> But if you are creating a navigation controller that has an array of navigation item:
$scope. Items = [
{state: ' Man ', Statepage: "man.html"},
{state: "Womanme", Statepage: "woman.html"}
]
Then use repeat in HTML:
<li repeat= "Item in Items" >
<a ui-sref= "{{item.statepage}}" ><{{item.state}}</a>
</ Li>
Ui-sref does not support dynamic binding, such code will be an error. You can only use the state name in the Sref, with a few parameters.
In this case, you can only give up sref and use back the href binding, and you could use $STATE.HREF to read the state URL.
The following is a brief introduction to the transfer of UI-SREF parameters
The page is written as follows
<a ui-sref= "man ({Id:1,name:2})" > button </a>
Routing inside Configuration:
$stateProvider. State (' man ', {
URL: '/man.html?id&name '), //parameter must first be declared here
Templateurl: '. /man.html ',
})
When you click on the connection, the browser's address becomes:/man.html/id=1&name=2
Or you can do it.
$stateProvider. State (' man ', {
URL: '/man.html ',
templateurl: '. /man.html ',
params: {' id ': null, ' name ': null},//parameter declared here
})
And then in the corresponding controller through the $stateparams value: $stateParams. ID, $stateParams. Name
In fact Ui-sref and $state.go is essentially a thing that can look at Ui-sref source
Element.bind ("click", Function (e) {
var button = E.which | | E.button;
if (!) ( button > 1 | | E.ctrlkey | | E.metakey | | E.shiftkey | | Element.attr (' target ')) {
var transition = $timeout (function () {
//We call $state. Go inside of ui-sref
$state. Go (ref.state, params, options);