Currently, my goal is to assign the class post
to my div with id #wrap
when I am on the page /post
. Here's what I have so far:
$routeProvider
when('/post', {
templateUrl : 'views/post.php',
controller : 'postCtrl'
})
Controller
carolvaladares.controller('postCtrl', function($scope) {
$scope.post = true;
});
HTML
<div id="wrap" ng-class="{true: 'post'}[post]">
When I access the /post
route, $scope.post
is set to true
. If $scope.post
is true
, then add the class post
to the #wrap
element.
However, the issue arises when I navigate to /post
; it doesn't recognize $scope.post
unless I manually use ng-controller="postCtrl"
.
Thank you in advance for your help.
-- EDITED --
After further investigation, I found that $scope.post
returns true
when using {{post}}
on the /post
page. Nevertheless, I still struggle with implementing ng-class
.
-- EDITED --
The problem persists because the #wrap
element is outside of my ng-view
. As a result, it seems that achieving my intended functionality may not be feasible with this current approach.