I have multiple views in an angular application. Currently, I am using ui.router's $stateProvider to establish the views. However I find this very tedious as I have to repeat each of the views in every state. Is there a way to set a default view for all states rather than repeat them in every state?
$stateProvider
.state('default', {
url: '/default',
views:{
view_1: {
templateUrl: 'view1',
controller: function($scope){}
},
view_2: {
templateUrl: 'view2',
controller: function($scope){}
},
view_3: {
templateUrl: 'view3',
controller: function($scope){}
}
}
})
.state('changed_state', {
url: '/changed_state',
views:{
view_1: {
templateUrl: 'view1',
controller: function($scope){}
},
view_2: {
templateUrl: 'changed_view2',
controller: function($scope){}
},
view_3: {
templateUrl: 'view3',
controller: function($scope){}
}
}
})
I want to only have to list the default views for all states once, and then only change the views that change with each state change. i.e.:
.state('default', {
url: '/default',
views:{
view_1: {
templateUrl: 'view1',
controller: function($scope){}
},
view_2: {
templateUrl: 'view2',
controller: function($scope){}
},
view_3: {
templateUrl: 'view3',
controller: function($scope){}
}
}
})
.state('changed_state', {
url: '/changed_state',
views:{
view_2: {
templateUrl: 'changed_view2',
controller: function($scope){}
}
}
})
Thanks