Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to set scope in template?

Tags:

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?

like image 591
Serhiy Avatar asked Jan 02 '17 09:01

Serhiy


People also ask

What is scope of template?

A scope of work is a form that provides a detailed explanation of work that will be performed as part of a contract or subcontract. A scope of work (SOW) is important because it helps ensure that the parties involved are on the same page regarding expectations related to the project.


1 Answers

You must use ng-init with "".

ng-init="item='myData'"

You need to compile it with scope.

container.append($compile(UIService.appendWorkItem(workItem))(scope));
like image 80
hurricane Avatar answered Sep 23 '22 10:09

hurricane