AngularJS directive -


i adding following div multiple times on page.

<div class="box span6">     <div class="box-header">         <h2 class="custom"><i class="fa-icon-group" style="opacity:.7"></i><span class="break"></span>[text]</h2>     </div>     <div class="box-content">         <p><strong>[text 2]</strong></p>         <ul>             <li ng-repeat = "course in courses">{{course}}</li>         </ul>     </div> </div> 

i'd write directive don't know how pass values directive.

eg. want pass "name" text , "email address" "text 2" , list of books "courses".

is there way pass values directive passing values function?

arguments function html attributes directive. in link , compile functions, attributes object, contains normalised names , values of attributes on element.

for example, have <div data-awesome-directive data-color="red" data-size="16"></div>. directive's link function link: function (scope, element, attributes) { ... }. in there, can access values of attributes properties of object: attributes.awesomedirective, attributes.color, , attributes.size. notice how names normalised (awesome-directive becomes awesomedirective).

for more advanced things, such function calls or expressions, $parse. can parse expression such foo.bar() , call on scope.

hth!


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -