나는 HTML <p>
태그를 기반으로 한 아주 간단한 단락 지시어를 만들었습니다.ng-transclude가있는 각도 지시문
<paragraph>This is a very simple paragraph</paragraph>
<paragraph></paragraph>
을 그리고 나는 ParagraphViewModel.text
에 바인딩 한 입력이 있습니다
angular.module('myApp').directive('paragraph', function() {
return {
restrict: 'E',
transclude: true,
controller: function() {
var vm = this;
vm.text = "Paragraph text from controller"
},
controllerAs: 'ParagraphViewModel',
template: '<p ng-transclude>{{ParagraphViewModel.text}}</p>'
}
});
나는 다음과 같이 내 HTML에서이 지시어를 사용하고 있습니다.
<input type="text" ng-model="ParagraphViewModel.text">
문제는 내가 입력을 변경할 때, 두 번째 <paragraph>
변화가 예상하지만 먼저 사람 값을하지 않는 것이다.
실제로 작동하는지 확인하려면 this JSBin을 확인하십시오.
그래서 모든 솔루션이 이거? – sadrzadehsina
무엇에 대한 해결책? :) 그것은 이런 식으로 행동해야합니다. 달성하려는 행동은 무엇입니까? –
@Dennis가 포인트를 얻었다. ng-transclude를 사용하면 각도가 태그를 대체합니다. –