ng-change 在 AngularJS 中當成 change event 使用

module.js

var ballApp = angular.module('BallApp', []);

ballApp.controller('LunchCtrl', function($scope) {
    $scope.change = function() {
        alert($scope.selectLunch);
    };
});

index.html

<div ng-controller="LunchCtrl">
    <select ng-model="selectLunch" ng-change="change()">
        <option value="0">請選擇</option>
        <option value="1">Hamburger</option>
        <option value="2">Rice</option>
    </select>
</div>
Categories: AngularJS