Question: how to set scope in template?

Question

how to set scope in template?

Answers 1
Added at 2017-01-02 10:01
Tags
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?

Answers to

how to set scope in template?

nr: #1 dodano: 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));
Source Show
◀ Wstecz