I am very new to Angular. I'm trying to dynamically change the value of ng-include in my header whenever the user selects a "facebook page". I cannot figure out why what I have is not working. I have tried everything I have found in stackoverflow and I stopped with these instructions: http://blog.dynamicprogrammer.com/2012/09/19/dynamic-includes-with-angular-js.html
This is my html:
<!-- BEGIN HEADER -->
<div data-ng-include data-ng-src="getPartial()" data-ng-controller="HeaderController"
class="page-header navbar navbar-fixed-top">
</div>
<!-- END HEADER -->
This is my controller:
* Setup Layout Part - Header */
PicoApp.controller('HeaderController', ['$scope', function ($scope) {
$scope.$on('$includeContentLoaded', function () {
Layout.initHeader(); // init header
});
$scope.getPartial = function () {
if (!FacebookPage.currentPage) {
location.href = "#/";
return 'tpl/header.html';
} else {
location.href = "#/";
return 'tpl/header_main_page.html';
}
}
}]);
In the div statement the function is added to ng-src which is not needed. Update the code to this