Currently, I am delving into the world of Angular and finding myself immersed in directive lessons. However, as I engage in some practice exercises, I have encountered a stumbling block.
Specifically, I have developed a custom directive with the intention that any text input by the user in the textbox will be displayed within my directive.
Regrettably, at this moment, the concept escapes me.
Allow me to share a snippet 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
}
});
I would greatly appreciate your assistance on this matter as I am relatively new to Angular.
For further reference, please find the Plnkr link below: