I am trying to call a function in a controller from an ng-included HTML file that includes a directive with its own template.
For example, the parent HTML template has this controller:
<div ng-controller="profileCtrl">
<div ng-include src="profileContent"></div>
</div>
profileCtrl:
$scope.profileContent = '/html/views/myview.html';
$scope.test = 'This should show';
myview.html:
<my-directive></my-directive>
myDirective:
angular
.module('myModule')
.directive('myDirective', [function () {
return {
restrict: 'E',
templateUrl: '/html/directives/myDirectiveTemplate.html',
...
myDirectiveTemplate.html:
{{test}} //This should display "This should show"
How can I access $scope.test from the child myDirective?
myDirectiveTemplate.html:
<form ng-submit="$parent.updateProfile()">
profileCtrl:
$scope.updateProfile = function() {
console.log('updating profile'); //this is not being called