javascript - angularjs link happens before replace -


in following code snippet need pull callclass attribute off element after template has been compiled , replaced. whenever try , attr object references parent element <servicedesk> not replaced template on attributes exist. how can fix this?

app.directive('servicedesk', ['_sys_ctx', '_sys_servicedesk', '_sys_dictionary',     function(_sys_ctx, _sys_servicedesk, dictionary) {         return {             restrict: "e",             scope: true,             templateurl: "partials/directives/servicedesk.html",             link: function(scope, elem, attr) {                 scope.data = _sys_servicedesk.retrieve(_sys_ctx);                 scope.scopename = "servicedesk_directive";                  var callclasses = dictionary.define('callclass');                 console.log(callclasses);                 attr.$observe('callclass', function(value) {                     console.log(value)                 });                 scope.callclass = callclasses[attr.callclass];             }          }     } ]); 

here template

<card ng-repeat="record in data" name="{{record.name}}" callclass="{{record.class}}">     <header>{{callclass}}</header>     <div class="calldetail">         <div class="userimg">             <img src="{{record.picture}}" alt="" />         </div>         <ul class="custinfo">             <li class="name">                 <h3>{{record.name}}</h3>             </li>             <li class="phone">                 <h3>{{record.phone}}</h3>             </li>             <li class="email">                 <h3>{{record.email}}</h3>             </li>         </ul>          <div class="summary">             {{record.summary}}         </div>     </div>      <ul>         <li>             <div class="description">                 {{record.description}}             </div>         </li>         <li>             <span class="status">                 {{record.status}}             </span>         </li>     </ul> </card> 

and view servicedesk element resides in has nothing more this

<servicedesk></servicedesk> 

if relevant view has own controller well. renders fine except callclass because when try log elem or attrs objects inside link function references <servicedesk> element not replacement template.

you can add property replace: true directive return object, <servicedesk> element replaced template access attrs of <card> tag.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -