我无法通过单击按钮来执行函数。我是刚接触angularjs的,我可能会犯一个愚蠢的错误。我需要建议,因为我尝试了以前的大多数解决方案。但是,它仍然不适合我。<script> var app = angular.module("myModule.controller", []); app.controller("bar_controller", [ "$scope", "$http", "$window", function($scope, $window, $http) { $scope.OperationalList = function() { $window.alert("calling function!"); $scope.name = data; $http({ method : 'post', url : '/com.az.BusinessRationAnalysis/reportGenerate', }).then(function(result) { $window.alert("succeed " + result.data); req.data={"nome":$scope.name}; $scope.jsonOperationalDataList = result.data; }, function(result) { $window.alert("Ajex call failed"); }); } } ])</script></head><body ng-app="myModule.controller"> <div ng-controller="bar_controller"> Name:<input type="text" data-ng-model="name" /> <button ng-click="OperationalList()">Display Report</button> <p>Hola {{name}}</p> </div> ```I need the window alert to work as a hint that my function is working
1 回答
陪伴而非守候
TA贡献1757条经验 获得超8个赞
更改 和 的顺序。始终遵循注入依赖项的顺序。$window$http
你应该functionfunction($scope, $http, $window)
添加回答
举报
0/150
提交
取消
