The data returned from my API is encoded. This is giving me some issues when setting the title of the page. My router sets the page title for static pages but for my dynamic "Project" pages, I'm setting the title via a controller. How can I make this output correctly?
<title ng-bind="pageTitle"></title>
Eg - My title "Tom’s app
" is being output as is...whereas I want it to be "Tom's app"
I've tried a filter with $sce but this doesn't change anything.
.filter('raw', function($sce) {
return function(input) {
return $sce.trustAsHtml(input);
}
})
//controller
$rootScope.title = $filter('raw')($scope.project.title);
My code:
.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl:'pages/home.html',
data : { pageTitle: 'Home' }
})
.when('/portfolio/:projectId', {
controller:'projectController',
templateUrl:'pages/project.html',
data : { pageTitle: 'Project' }
})
.when('/portfolio', {
controller: 'portfolioController',
templateUrl: 'pages/portfolio.html',
data : { pageTitle: 'Portfolio' }
})
.when('/contact', {
controller: 'contactController',
templateUrl: 'pages/contact.html',
data : { pageTitle: 'Contact' }
})
.otherwise({
redirectTo:'/'
});
})
.run(['$location', '$rootScope', function($location, $rootScope) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
$rootScope.title = current.$$route.data.pageTitle;
});
}])
.controller('projectTitle', function($scope, $location, $rootScope, $routeParams, $http, $sce, $filter, WPAPI) {
$rootScope.title = $scope.project.title;
})