控制器没有加载我的场景
controller not loading my scenario
我收到错误而不是加载我的controller
。
我提供了我所有的文件,请让任何人找出错误。
html文件:<!DOCTYPE html>
<html ng-app="tcpApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<base href="/">
<title>TCP App</title>
<link rel="stylesheet" href="css/lib/fonts.css">
<link rel="stylesheet" href="css/lib/reset.css">
<link rel="stylesheet" href="css/tcp.css">
</head>
<body>
<div class="wrapper" ng-view></div>
<!--Libs -->
<script src="js/lib/jquery/dist/jquery.min.js"></script>
<script src="js/lib/angular/angular.min.js"></script>
<script src="js/lib/angular-resource/angular-resource.min.js"></script>
<script src="js/lib/angular-route/angular-route.min.js"></script>
<!--scripts -->
//loading controller as first
<script src="js/script/controllers/homeController.js"></script>
<script src="app.js"></script> //app file
</body>
</html>
app.js:
"user strict";
var tcpAppHolder = angular.module("tcpApp", ["ngRoute"]);
tcpAppHolder
.config(function ($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when ("/home", {
templateUrl : "views/home.html",
controller : "homeController" //loading home controller
});
$routeProvider
.otherwise ({
templateUrl : "views/home.html",
controller : "homeController"
});
});
homecontroller.js文件:
"use strict";
angular.module("tcpApp.controllers")
.controller("homeController", function ($scope) { //but not loading
console.log("i am from home");
});
错误:
Uncaught Error: [$injector:nomod] http://errors.angularjs.org/1.4.0/$injector/nomod?p0=tcpApp.controllers
请使用
更新家用控制器angular.module("tcpApp")
.controller("homeController", function ($scope) { //but not loading
console.log("i am from home");
});
您的模块名称不正确,导致了这个问题。
您的模块名称是tcpApp
,而不是tcpApp.controllers。编辑你的homecontroller.js文件。
angular.module("tcpApp")
.controller("homeController", function ($scope) { //but not loading
console.log("i am from home");
});
需要添加tcpApp。
var tcpAppHolder = angular.module("tcpApp", ["ngRoute", "tcpApp.controllers" ]);
相关文章:
- 我的加载更多功能适用于按钮单击,但它不适用于滚动
- jQuery 限制我正在加载/追加的字符数
- 优化 CSS 交付.但我正在加载 JS 的样式
- $(窗口).on('scroll',函数 () 当滚动到 50% 时,我想加载很少的数据
- jQuery Mobile添加了我可以加载的文本't拆卸
- 当我重新加载页面时,我放在文本框中的文本保持不变,我能让这种情况不发生吗
- 我如何加载javascript模板与他们的id
- require.js:我如何加载一个模块,它在不同的名称下定义了一个名称
- 为什么我的加载处理程序不起作用
- 我如何在网站上加载特定的字体与较少的加载时间
- 当我重新加载页面时,我之前的评论消失了——这与本地存储有关
- 我可以订阅openwindow的加载事件吗?
- Jstree:当我重新加载树时,我不能将所有的复选框重置为默认取消选中
- 我可以加载一个新的页面时,有人点击关闭按钮在浏览器上
- 为什么以及如何在console.log中引用变量来修复我遇到的加载错误?
- 我的加载更多的按钮是不显示,尽管一切都是正确的,根据我
- 为什么我的加载更多的按钮后,ajax加载需要另一个点击它之前隐藏,即使没有什么要加载
- 如何优化我的加载JQuery函数
- 为什么我的加载没有'不起作用
- 当加载html与ajax在jQuery,我怎么能确保我的加载gif保持可见的整个时间,直到html已添加