单击按钮无法执行功能。我是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
答案 0 :(得分:1)
更改$window
和$http
的顺序。始终遵循注入依赖项的顺序。
您的function
应该是function($scope, $http, $window)