I am studying Angular now and I am in the directive lesson. And I am doing some exercise for myself but I have a problem.
I created a customer directive and what I want is the user will input any text in the textbox then the text from the input will be displayed in my custom directive.
Right bow I still don't get it.
Here's some of my code:
<body ng-app="myApp">
<div class="container" ng-controller="MainCtrl">
<h3>Directive</h3>
<div class="form-group">
<label>Type text: </label>
<input type="text" class="form-control" ng-model="greet_value" />
<p>Value <div flx-greet-me></div></p>
</div>
</div>
</body>
my directive:
var myApp = angular.module('myApp',[]);
myApp.controller('MainCtrl', function(){
//some codes here
})
.directive('flxGreetMe', function() {
var html_template = '<h1>' + $scope.greet_value + '</h1>';
return {
replace: true,
restrict: 'AE',
scope: true,
template: html_template
}
});
Can you help me with this? I am still new in Angular.
Here's the plnkr: