Presently, I have a single factory structured as follows:
export function PageFactory() {
var title = 'default';
return {
title: function() { return title; },
setTitle: function(newTitle) { title = newTitle }
};
}
Within a controller, I am injecting the factory in this manner:
constructor(private $scope:IMainScope, $rootScope, $window, $route, Page) {
Page.setTitle('home');
}
My objective is to showcase the variable in the view using {{ Page.title }}
. However, this approach does not yield the desired outcome. The only way it works is if I inject the factory and assign the title to a variable in the controller like so:
constructor(private $scope:IMainScope, $rootScope, $window, $route, Page) {
$scope.title = Page.setTitle('home');
}
Subsequently displaying the variable as: {{ title }}
. Nevertheless, my preference would be to achieve this without such additional steps.