I have the state configuration defined in as follows:
angular.module('app', ['ui.router')
.config(function ($stateProvider, $urlRouterProvider) {
.state('element', {
url: '/element',
templateUrl: 'element.html',
controller: 'ElementCtrl',
controllerAs:'ec',
data: {
title: 'Element {{ec.name}}',
}
})
.state('element.detail', {
url: '/detail',
templateUrl: 'detail.html',
controller: 'HomeCtrl',
controllerAs:'hc',
data: {
title: 'Detail {{hc.age}}',
}
})
.controller('ElementCtrl', function ($scope, $stateParams) {
this.name = "myName";
})
.controller('HomeCtrl', function ($scope, $stateParams) {
this.age = "myName22";
});
Here, I want to dynamically determine the data.title field based on the value assigned to the variable in the controller. Is there a way to do this?(It is better if I do this before the state is activated).