【问题标题】:Shared scope directives with a ngModel in the template模板中带有 ngModel 的共享范围指令
【发布时间】:2016-02-20 10:47:08
【问题描述】:

有类似的东西:

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

这不绑定到模型,我可以让它工作的唯一方法是在范围内指定一个变量:{},然后使用它,这实际上是我不想要的。

有什么解决办法吗?

【问题讨论】:

    标签: angularjs angularjs-directive angularjs-scope angularjs-ng-model


    【解决方案1】:

    您无需在视图中提及$scope

    这样试试

    <input ng-model="myVar"></input>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-17
      • 2016-01-12
      • 1970-01-01
      • 1970-01-01
      • 2015-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多