0

有類似:共享範圍的指令與ngModel模板

module.directive('myCustomInput', function($compile) { 
     return { 
      restrict: 'E', 
      template: '<input ng-model="$scope.myVar"></input>' 
     } 
} 

這不結合的模式,我可以做它的工作的唯一方法是通過指定範圍的變量:{ },然後使用它,這實際上是我不想要的。

有沒有解決方法?

回答

1

你並不需要提及$scope鑑於

嘗試這樣

<input ng-model="myVar"></input> 
相關問題