I am trying to use the restrict
option with the value 'M'
(for angular work through comments) to create a directive. But the comment is not embedding the value I'm adding in template
.
See:
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>
IfIdowithA
orE
(toreadattributesorelementsrespectively),itworksperfectly:
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>