在Foundation for Apps中,选择时不会触发ng-change

时间:2016-04-22 09:53:20

标签: angularjs zurb-foundation zurb-foundation-apps

在Foundation-for-Apps Web应用程序中,我想在选择值更改时在控制器中触发一个函数。

我在模板中执行了以下操作:

puts 'Hello, what\' your favorite number?'
number = gets.to_i
puts 'Here\' a better bigger favorite number - ' + (number + 1).to_s
# or 
bigger_number = number + 1
puts 'Here\' a better bigger favorite number - ' + bigger_number.to_s
# or 
puts "Here's a better bigger favorite number - #{bigger_number}"

我的控制员:

---
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>

应该工作:提供(function() { 'use strict'; angular.module('application').controller('MeetingRoomsCtrl', ['$scope', function($scope, $state, $window, foundation, ModalFactory, NotificationFactory) { $scope.selectLocationChanged = function() { console.log($scope.selectLocation.name); }; } ]); })(); ,范围中存在函数ng-model(我可以使用同一模板中控制器中设置的其他变量)和语法{{ 1}}是正确的。我在控制台中没有任何错误消息,更改事件不会被触发。

有什么理由不行吗?也许是基金会申请的具体内容?

1 个答案:

答案 0 :(得分:0)

将您的代码更改为此,忘记在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>