Path route view to view by id


#1

Hello guys im struggeling with ionic and angular i build an news site view with thumbnail menu i wrote my news in an array

for example

code example

 .controller('NewsCtrl', function($scope) {

    var items = [
        {id: 1, news_item: 'NEWS EXAMPLE'}
    ];

});

how can i route the right path to the news_item.html site which i klicked on. so if i click on first one i get the tempalte with ‘NEWS EXAMPLE’


#2

You should user url paramemters i.e

route settings:

.state('NewsDetails', {
        url: '/NewsDetails/:newsID',
        templateUrl: '/NewsDetails.html',
        controller: 'NewsDetailsCtrl'
    })

controller:

.controller('NewsDetailsCtrl', function($scope, $stateParams) {
   var news_id = $stateParams.newsID;
   ....
})

use like this:
/NewsDetail/NEWS_ID
e.g /NewsDetail/1
Hope that helps.


#4

Thank u so much u made my day :smile: