Why doesn't the two way binding work in the following directive?
Module:
angular.module('main')
.controller('MainController', ['$scope', 'TestService', function ($scope, TestService) {
$scope.name = "Aaron";
$scope.data = "Initial";
$scope.dataClicked = function () {
alert($scope.data);
};
}]);
Directive:
var angularStartDirectives = angular.module('angularStart.directives', []);
angularStartDirectives.directive('outputText', function () {
return {
transclude: true,
template: '<div ng-transclude></div>'
};
});
Form:
<form>
<div data-output-text>
<p>Hello {{name}}</p>
<input type="text" ng-model="data" />
</div>
<div>{{data}}</div>
<button type="button" ng-click="dataClicked()">Go</button>
</form>
The result is that the transcluded content receives the value of $scope.data
initially but updates to the bound input do not propagate up to the parent scope.