I have a module in my application which shares same controller and services for two views under it. However my view 1 page title is set to be Home in the controller's init function like this
//module.js
import angular from 'angular';
import 'angular-ui-router';
import 'd3';
import 'jquery';
// Controllers
import controller from './moduleoneController.js';
let path = './modules/moduleone/';
let modone = angular.module('modone', [
'ui.router'
])
// Controllers
.controller('moduleoneCtrl', moduleoneCtrl)
// Routes
.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('moduleone', {
url: '/moduleone',
controller: 'moduleoneCtrl',
templateUrl: path + 'views/one.html',
})
.state('view2',{
url: '/view2',
controller: 'moduleoneCtrl',
templateUrl: path + 'views/two.html',
});
}]);
export default moduleone;
//in my controller title is being set like this
this.init = function () {
someService.setPageTitle('Home');
};
init();
//html
<div header-text="{{oneCtrl.title}}"></div>
but when I am using this controller for view 2 I cannot change the title to the one I wanted, How do we change it in such cases ?