javascript - AngularJS: how render directive from controller's variable? -



javascript - AngularJS: how render directive from controller's variable? -

in controller:

$scope.directivename = 'hello-world';

my directive:

app.directive('helloworld', [ function() { homecoming { restrict: 'eac', link: function(scope, ele, atr) { console.log('hello world directive'); } } }]);

in html:

<div class="{{directivename}}"></div>

why not work? how can behavior?

just utilize ng-bind directive add together custom directive html

<div class="ng-bind:'directivename'"></div>

angular doc

update directive supports class,attribute , tag. can utilize directive in format also.

<div {{directivename}}></div>

javascript angularjs angularjs-directive

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -