【问题标题】:select not working moving to angular controller as选择不工作移动到角度控制器作为
【发布时间】:2014-11-05 07:34:01
【问题描述】:

我有一个使用 typescript 编写的程序,我正在升级到 angular 1.3,并且我正在将控制器转换为作为模型的控制器,但我遇到了一个问题。
我有一个这样定义的选择:

<select id="soluzione" name="soluzione"
        class="required"
        ng-options="soluzione.id as soluzione.denominazione for soluzione in soluzioni"
        ng-model="soluzioneCorrente"
        ng-change="filtroSoluzione()">

其中 soluzioni 是在控制器构造中使用 ajax 调用加载的数组。使用具有范围的控制器,列表被正确填充。
更新后我将定义更改为

<select id="soluzione" name="soluzione"
        class="required"
        ng-options="soluzione.id as soluzione.denominazione for soluzione in vm.soluzioni"
        ng-model="vm.soluzioneCorrente"
        ng-change="vm.filtroSoluzione()"></select>

但选择不再加载。
我错过了什么?用batarang检查看起来范围被正确暴露并且其他事件处理程序以正确的方式被调用,所以我想我转换了控制器。

卢卡

【问题讨论】:

  • 您能发布更多关于控制器外观的代码或创建一个 jsFiddle 吗?乍一看,我认为您不需要“vm”。
  • 能否请您显示数据解决方案。不需要使用 VM。请出示您的控制器,然后我们可以看到您的 $scope 的状态。如果您可以制作一个 jsFiddle 示例,那将非常有帮助
  • 嗨,我也面临同样的问题。你能在哪里解决这个问题?

标签: angularjs typescript


【解决方案1】:

确保您的 HTML 中有 ng-controller="SomeController as vm"

【讨论】:

    猜你喜欢
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 2015-04-25
    • 1970-01-01
    • 1970-01-01
    • 2016-03-01
    • 1970-01-01
    • 2014-02-02
    相关资源
    最近更新 更多