【问题标题】:Angular binding not working in Chrome/OperaAngular 绑定在 Chrome/Opera 中不起作用
【发布时间】:2014-04-17 00:11:34
【问题描述】:

您好,这个 JSFiddle 在 Internet Explorer 和 Firefox 中工作,但没有其他浏览器工作。代码的想法是使用 Yahoo Currency API 进行最新的货币转换器。它不会像在 Chrome 上那样更新其他浏览器上的 $scope。 http://jsfiddle.net/xHmLT/13/ 选择一个帖子({{visible.post}} 可见)

    <select>
        <option  ng-repeat="shot in shots" ng-click="visible.post = shot.Name" value="{{shot.Name}}">{{shot.Name}}</option>
    </select>

<div ng-repeat="shot in shots" ng-if="visible.post == shot.Name">{{shot.Rate | currency:'':''}}

</div>

   <div ng-repeat="shot in shots" ng-if="visible.post == shot.Name">{{shot.Rate *5 | currency:'':''}}

</div>

【问题讨论】:

    标签: javascript css angularjs google-chrome


    【解决方案1】:

    我更新了您的 fiddle 并且正在按照您的预期工作...

    您的选择现在通过 ng-options 填充,并且模型是 visible.post(作为对象)。结果,在任何地方显示 visible.post,现在都显示 visible.post.Name(对象上的字段)

    <select ng-options="s.Name for s in shots" ng-model="visible.post"></select>
    

    选定值的初始化在成功承诺处理程序中完成:

    $scope.visible.post = $scope.shots[0];
    

    【讨论】:

      猜你喜欢
      • 2019-04-09
      • 2012-08-20
      • 2011-07-05
      • 2010-10-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-26
      相关资源
      最近更新 更多