gpt4 book ai didi

javascript - AngularJs View 不显示

转载 作者:行者123 更新时间:2023-11-30 00:33:35 25 4
gpt4 key购买 nike

嗨,我是 Angular JS 的新手。当我加载页面时它显示两个错误

1 - 错误:[$injector:unpr]

2 - 错误:[$injector:cdep]

HTML

index.html

<body ng-app="MyApp">
<nav>
<!-- navbar items displaying here -->
</nav>
<div ng-view></div>
</body>
<script src="libs/js/angular.js"></script>
<script src="libs/js/angular-route.min.js"></script>
<!--angular controller file-->
<script src="libs/apps.js"></script>
<script src="libs/controller.js"></script>
<!--Other UI Libraries-->
<script src="libs/js/jquery.min.js"></script>

partials/developers.html

  <section class="developer">

<div class="container-fluid">
<div class="col-md-9 col-md-offset-3">
<form ng-submit="check()">
<div class="form-group">
<div class="col-md-6">
<input type="text" class="form-control" autofocus="true" ng-model-options="{debounce: 300}" ng-model="search" placeholder="Search text here"/>
</div>
</div>

</form>
</div>
<div class="sort col-md-5 col-md-offset-3">
<label class="formgroup">Sort By</label>
<select ng-model="order">
<option value="name" selected="selected">
Name
</option>
<option value="org">
Organisation
</option>
<option value="designation">
Designation
</option>
</select>
<label class="formgroup">
<input ng-model="direction" type="radio" name="order" checked>
Ascending
</label>
<label class="formgroup">
<input ng-model="direction" type="radio" name="order" value="reverse">
Descending
</label>

</div>
<div class="col-md">
<div class="col-md-9 col-md-offset-3">
<div class="col-md-6 mydiv" ng-clock>
<ul ng-show="search ">
<li class="items" ng-repeat="item in list | filter:search | orderBy:order:direction" ng-model-options="{ updateOn: 'blur' }">
<label class="lbl">Name</label><p class="text name" ng-bind="item.name"></p>
<label class="lbl">Designation</label><p class="text desig" ng-bind=" item.designation"></p>
<label class="lbl">Organisation</label><p class="text org" ng-bind="item.org"></p>
<div class="clear"></div>
</li>
</ul>
</div>

</div>

</div><!--Container fluid closes-->

</section>

app.js

var myApp = angular.module("MyApp",[
'ngRoute',
'appController'
]);

myApp.config(['$routeProvider',function($routeProvider){
$routeProvider.
when('/list',{
templateUrl : 'partials/developers.html',
controller:'DeveloperController',
}).
otherwise({
redirectTo: '/list'
});

}]);

controller.js

var appController = angular.module("appController", []);
appController.controller('DeveloperController', ['$scope','$http',function($scope,$http) {

$scope.name="asdsas";

}]);

查看控制台图像 here

编辑

this是我的项目目录结构。会不会有什么麻烦。我没有在 wamp 或任何其他服务器上运行它。

谁能帮我解决一下

最佳答案

错误是由于缺少包含 ngRoute 模块引起的。需要单独包含

尝试在您的脚本中包含以下内容

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>

引用this了解更多详情。

关于javascript - AngularJs View 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28232737/

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