简体   繁体   English

ng-change未在Foundation for Apps中启用

[英]ng-change isn't firing on select in Foundation for Apps

On a Foundation-for-Apps web application, I want to trigger a function in my controller when a select value is changed. 在“应用程序基础” Web应用程序上,当选择值更改时,我想在控制器中触发一个功能。

I did the following in my template: 我在模板中执行了以下操作:

---
name: meeting-rooms
url: /meeting-rooms
controller: MeetingRoomsCtrl
animationIn: slideInRight
animationOut: slideOutLeft
---

<div class="custom-tabs" zf-tabs="">
    <div class="custom-tabs-item" zf-tab="" title="Location" data-options="one_up: false">
        <form class="form">
            <select id="selectLocation" class="select form-place-select" ng-model="selectLocation" ng-change="selectLocationChanged()">
                <option value="">Select a place</option>
                <option value="New York">New York</option>
            </select>   
        </form>
    </div>
</div>

And my controller: 而我的控制器:

(function() {
    'use strict';

    angular.module('application').controller('MeetingRoomsCtrl', ['$scope',
        function($scope, $state, $window, foundation, ModalFactory, NotificationFactory) {
            $scope.selectLocationChanged = function() {
                console.log($scope.selectLocation.name);
            };
        }
    ]);
})();

Which is supposed to work: the ng-model is provided, the function selectLocationChanged exist in the scope (I can use other variables set in the controller in the same template), and the syntax ng-model="selectLocation" ng-change="selectLocationChanged()" is correct. 应该起作用:提供了ng-model ,作用域中存在函数selectLocationChanged (我可以在同一模板中使用控制器中设置的其他变量),语法为ng-model="selectLocation" ng-change="selectLocationChanged()"正确。 I don't have any error message in the console, the change event is just not fired. 我在控制台中没有任何错误消息,只是未触发change事件。

Is there any reason why this is not working? 有什么原因不能奏效吗? Maybe something specific with Foundation For Apps? 也许与Foundation for Apps有关?

Change your code to this, forgot to include controller in HTML page 将您的代码更改为此,忘记在HTML页面中包含控制器

<form class="form" ng-controller="MeetingRoomsCtrl">
     <div  >
      <select id="selectLocation" class="select form-place-select" ng-model="selectLocation" ng-change="selectLocationChanged(selectLocation)">
           <option value="" disabled="disabled">Select a place</option>
           <option value="New York">New York</option>
     </select>
    </div>
   </form>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM