gpt4 book ai didi

angularjs - 错误: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=NaNnvalidProvider%20%3C-%20%24invalid%20%3C-%20Ctrl

转载 作者:行者123 更新时间:2023-12-03 08:53:19 26 4
gpt4 key购买 nike

我在 Controller 中有此代码

app.controller('Ctrl', function($scope, $invalid, $location) {
$scope.upd_check = function()
{
console.log($scope.MyForm);
if($scope.MyForm.$invalid){
$("#modal_traffic_incorrect").modal('show');
}

}

我的html代码是
 <form name="MyForm">
<div class="item_title">Text</div>
<div class="item_contentbox">
<input class="inputs len_md" name="number" ng-model="text" ng-required ng-pattern="/^([1-9])$/" >

</div><br />
<div class="col-md-offset-1 col-md-10 col-sm-12 text_right">
<button type="submit" class="button" ng-click="upd_check()">Save</button><br><br><br>
</div>
</form>

</div><br />

并且我收到此错误:错误:[$ injector:unpr] http://errors.angularjs.org/1.4.8/ $ injector/unpr?p0 = NaNnvalidProvider%20%3C-%20%24invalid%20%3C-%20Ctrl

我该怎么解决呢?谢谢您的帮助

最佳答案

Error: $injector:unpr

This error results from the $injector being unable to resolve a required dependency. To fix this, make sure the dependency is defined and spelled correctly. For example:


angular.module('myApp', [])
.controller('MyController', ['myService', function (myService) {
// Do something with myService
}]);

如果未定义myService,以上代码将以$ injector:unpr失败。

如下所述,确保定义了每个依赖关系都会解决此问题。
angular.module('myApp', [])
.service('myService', function () { /* ... */ })
.controller('MyController', ['myService', function (myService) {
// Do something with myService
}]);

因此,就您而言,请尝试:
app.controller('Ctrl', ['$scope','$invalid','$location',function($scope,$invalid, $location) 
{}];

关于angularjs - 错误: [$injector:unpr] http://errors.angularjs.org/1.4.8/$injector/unpr?p0=NaNnvalidProvider%20%3C-%20%24invalid%20%3C-%20Ctrl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35307652/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com