Because I make requests of the pages with their own name (Meaning: no id)
and I want my query to the server will be based on id !
and not according of the name of the page. Because Then the query will be twice ..
And I want to get in controller The id
So I thought to put ids in all my <a>
within property data-page-id
But I can not find able to access to it, from the state
-
to the property data
in <a>
elements
Ps
I saw that can be do ui-sref-active
Directive
To make class 'active' for current page
so I thought that if there is a possibility to ui-route
to identify what is link is pressed
Maybe there a possibility also to accept id
that I will plant in the <a>
objects
Here is my controller:
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
$stateProvider
.state('pages', {
url: '/:page',
templateProvider:['$templateRequest',
function($templateRequest){
return $templateRequest(BASE_URL + 'assets/angularTemplates/pages.html');
}],
controller: function($scope, $http){
if(window.content){ // Here the server sending json when if is it a first loading to the particular page and not coming from the home page
$scope.contentPage = window.content;
delete window.content;
}
else {
var pageID = 2; // Here I want to access an object attribute <a> to get the id
$http.get(BASE_URL + '?Angular_pageID=' + pageID)
.then(function(res){
$scope.contentPage = res.data;
});
}}
})
Here is my HTML code:
<ul class="nav nav-tabs nav-justified">
<li ui-sref-active="active"><a ui-sref='pages({page: ""})'>Home</a></li>
<li ng-repeat="menu in menus" ng-if="!$first" ui-sref-active="active"><a ui-sref='pages({page: menu.url })' data-id-page='{{menu.id}}'>{{menu.link}}</a></li>
</ul>