2

I have the following code:

<div ng-include src="{{ headerLocation }}"></div>

And I have the following code in my controller:

var ER = angular.module('evidenceReviewerApp');

ER.controller('MainCtrl', function ($scope, appData, $location, $cookies) {

    // Some code

    if ( !! $cookies.loggedin || $cookies.loggedin == 'true' )
        $scope.headerLocation = 'login-header.html';
    else
        $scope.headerLocation = 'anon-header.html';

});

Of course I get the error Error: [$parse:syntax] Syntax Error: Token 'headerLocation' is unexpected, expecting [:] at column 4 of the expression [{{ headerLocation }}] starting at [headerLocation }}].

What I want to do is show a different partial depending on whether the user is logged in or not.

1 Answer 1

5
<div ng-include="headerLocation"></div>

that's all.

Sign up to request clarification or add additional context in comments.

1 Comment

Oops. Still getting used to Angular as you probably can tell ;) Thanks for the answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.