2014-10-31 4 views

답변

0

Scope in Directives

당신은 아래의 JSFiddle Here 또는를 볼 수 있습니다.

또한 여기는 great article on the subject입니다.


JS 바이올린 코드

<div ng-controller="MyCtrl"> 
    <pass-object obj="obj2" itm="item.one"></pass-object> 
</div> 

JS VAR MyApp를 angular.module = (화상의 표시) ('하는 MyApp'[]);

myApp.directive('passObject', function() { 
    return { 
     restrict: 'E', 
     scope: { object: '=obj', itm: '=' }, 
     template: '<div>Hello, {{object.prop}}, {{itm}}!</div>' 
    }; 
}); 

myApp.controller('MyCtrl', function ($scope) { 
    $scope.obj2 = { prop: "world" }; 
    $scope.item = {"one": 1, "two": 2}; 
}); 
관련 문제