I'm using angularjs with ui-router (with the helper stateHelperProvider) to collect views and controllers into the page.
But got a problem with my views not updating.
My code (the one that is related)
config.js
app.config(function($httpProvider, $urlRouterProvider, RestangularProvider, stateHelperProvider) {
$urlRouterProvider.otherwise("/");
stateHelperProvider
.state({
name: 'division',
url: '/division/:division',
views: {
'main': {
templateUrl: '/templates/division.main?uri=' + segment(2),
controller: 'DivisionController'
}
},
children: [
{
name: 'appcontent',
url: '/content',
views: {
'content': {
templateUrl: "templates/division.appcontent?uri=" + segment(2) + '&root=' + segment(4),
controller: 'AppContentController'
}
},
children: [
{
name: 'root',
url: '/:root',
views: {
'roots': {
templateUrl: "templates/division.appcontent.roots?uri=" + segment(2) + '&root=' + segment(4)
}
}
}
]
}
]
});
});
the code I use for linking
// linking to another division
<a ui-sref="division.appcontent({division: 'test2')">test2</a>
// linking to another root
<a ui-sref="division.appcontent.root({division: 'test2', root: 'test')">test2</a>
Explaining
But got a problem with my views not updating.
My views are the one with the actual data, so I need them to reload on change.
Like when :division in url is test1, then the template template/division.main have one set of data. But when :division in url is test2, then the template template/division.main have another set of data.
So whenever :division in url changes, I need to reload the template template/division.main and as well all the child templates.
But when :root changes in the url, I only need to reload the template template/division.appcontent.roots and not the template/division.main template.
Is this possible somehow or should I change to use only an API in order to get data.
I really hope this makes sense.
Note
segment is a function I have made to get some data from the angular route.