Help to get the value from a custom-directive
I have the following code, all I need is to be able to get the value that the text field gets when it is type.
The getName function should change the displayed name.
I add the code:
'use strict';
angular
.module('app', [])
.controller("Controller", function ($scope) {
$scope.getName = function() {
return $scope.name;
};
})
.controller("EditController", function($scope) {
$scope.editingMode = true;
})
.directive("newName", function ($parse) {
return {
template: 'Write name: <input type="text" ng-model="name">'
};
});
Angular
<div ng-controller="Controller">
<h1>Hello, {{ getName() }}</h1>
<div ng-controller="EditController">
<new-name ng-show="editingMode"></new-name>
</div>
</div>