簡體   English   中英

angularjs ng-click 不起作用

[英]angularjs ng-click not working

JavaScript 定義控制器,然后通過$hhtp調用函數,並在$scope定義我想調用的模型和函數:

 myApp.controller('ProfileTweets', ['$scope', '$http', '$location', function ($scope, $http, $location) { $http({ url: '../ProfilesName/', method: 'GET' }).then(function (itemdata) { $scope.ProfilesName = itemdata.data; }); $scope.loaddata = function () { alert('hiii'); } }]);

在 html 中,我正在調用函數loaddata()如下面的代碼所示

 <div class="form-group"> <select class="form-control" dir="rtl" style="width:100%;" ng-model="ProfilesName" ng-options="Profiles.profile_name for Profiles in ProfilesName" ng-change="loaddata()"> </select> </div>

ng-change不起作用,什么也沒有發生。 如何解決?

我猜你忘了放置 ng-controller 指令,沒有它它就無法工作

 myApp.controller('ProfileTweets', ['$scope', '$http', '$location', function ($scope, $http, $location) { $http({ url: '../ProfilesName/', method: 'GET' }).then(function (itemdata) { $scope.ProfilesName = itemdata.data; }); $scope.loaddata = function () { alert('hiii'); } }]);
 <div class="form-group" ng-controller="ProfileTweets"> <select class="form-control" dir="rtl" style="width:100%;" ng-model="ProfilesName" ng-options="Profiles.profile_name for Profiles in ProfilesName" ng-change="loaddata()"> </select> </div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM