0
I’m trying to use the option restrict
with the value 'M'
(for the angular work through comments) to create a directive. However the comment is not incorporating the value I am adding into template
.
Behold:
angular.module('example', [])
.directive('stackoverflow', function () {
return {
restrict: 'M',
template: '<div>my name is wallace</div>'
};
});
<div ng-app="example">
<!-- directive: stackoverflow -->
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
If I do with the A
or E
(to read attributes or elements respectively), it works perfectly:
angular.module('example', [])
.directive('stackoverflow', function () {
return {
restrict: 'AE',
template: '<div>my name is wallace</div>'
};
});
<div ng-app="example">
<div stackoverflow></div>
<stackoverflow></stackoverflow>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.7/angular.min.js"></script>
Why the directive with restriction M
did not work in the first example?
Worked great.
– Flavio Misawa