how to set scope in template?

Question

Hi I append created element to parent:

  container.append(UIService.appendWorkItem(workItem));

UIService

 function appendWorkItem(item) {
         return '<div  layout="column" ng-init=item='+item+' class="md-whiteframe-1dp workItem  workItemName" id='+item._id+'child> <div layout="row"  layout-align="space-between"  ng-click="workItemActivate('+item+')" ng-dblclick="openItemEdit('+item+')"> <div>'+item.name+'</div> <div> <md-icon md-font-icon="zmdi zmdi-share"  title="Has parent child connection"></md-icon> </div> </div> <div class="dragulaParentDOM" > <div dragula="first-bag"  id="'+item._id+'containerWorkItem" class="itemChildContainer"></div> </div> </div>'
    }

I would like to set scope.item into this temlate. I use for it

ng-init=item='+item+'  

but it doesn't work. how to do it?


Show source
| angularjs   | angularjs-scope   2017-01-02 10:01 1 Answers

Answers to how to set scope in template? ( 1 )

  1. 2017-01-02 10:01

    You must use ng-init with "".

    ng-init="item='myData'"
    

    You need to compile it with scope.

    container.append($compile(UIService.appendWorkItem(workItem))(scope));
    

Leave a reply to - how to set scope in template?

◀ Go back