angularjs - how does angular compile attribute into directives -


i want able have second directive phone compiled alert, how should this

<div ng-app="website">     <div ng-controller="mycontroller">             <div phonebook="phone">  phonebook</div>     </div> </div> 

http://jsfiddle.net/x3azn/apwg8/1/

your problem using ng-class declarative class (to instantiate directives). not work, classes ng-class adds elements added after compilation, , such not recognized $compile function.

replacing

var template = '<div ng-class="{phone2: number}" >phone</div>'; 

with

var template = '<div class="phone2">phone</div>'; 

will make work.

i did not understand why associated number phone2 directive wanted instantiate figure 1 of 2 things: either include conditionally, or bind numbermodel directive. if want create conditionally appearing directive, 1 way use ng-switch, including directive below it.

if wanted create data binding, however, such:

var template = '<div class="phone2" data-number="number">phone</div>'; 

including reference binding in directive:

.directive('phone2', function($compile){ return {     restrict: 'ac',     scope:{number:"="},     link: function(s,e,a,c){ 

posted slighly mended edit of code here: http://jsfiddle.net/apwg8/2/


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -