- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我觉得我快疯了,因为答案应该很简单,我是 angular 和 nodejs 的新手,我正在尝试制作一个将它们结合起来的应用程序。
"Error: [$injector:nomod] Module 'myApp' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument."
公共(public)/ Controller /家庭 Controller :
(function () {
'use strict';
angular.module('myApp').controller('homeController', homeController);
function homeController() {
var vm = this;
vm.fillerData = "FillerData"
}
}) ();
public/Index.html:
<!DOCTYPE html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Dit is de index</title>
<script src="res/js/angular.js" type="text/javascript" defer="defer"></script>
<script src="controllers/homeController.js" type="text/javascript" defer="defer"></script>
</head>
<h1>What</h1>
<body ng-controller="homeController as homeCtrl">
{{ homeCtrl.fillerData }}
</body>
</html>
路由器/index.js:
var router = require('express').Router();
router.get('/index', function (req, res) {
res.sendfile('public/index.html');
});
router.get('/home', function (req, res) {
res.sendfile('public/home.html');
});
module.exports = router;
和/server.js:
var express = require('express');
var app = express();
var routes = require('./router');
app.use(express.static(__dirname + '/public'));
app.use('/', routes);
require('router/index.js')(app);
app.listen(3000);
console.log("App listening on port 3000");
所有必要的软件包也已安装,如有任何帮助,我们将不胜感激
最佳答案
如果你想创建一个新的module
,你需要传递一个空的array
作为第二个参数(如果你对其他模块有依赖,而不是告诉模块在数组中),这将告诉 Angular 您正在创建一个新模块。
Beware that using angular.module('myModule', []) will create the module myModule and overwrite any existing module named myModule. Use angular.module('myModule') to retrieve an existing module.
angular.module('myApp',[]).controller('homeController', homeController);
如果你想获得已经创建的模块,那么你需要像这样调用
angular.module('myApp',[])....
关于javascript - Angular 和 NodeJS 模块 'foo' 不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41933785/
public class Foo : IFoo ... 和有什么区别 IFoo foo = new Foo(); 和 Foo foo = new Foo(); 最佳答案 区别仅在于变量的声明类型。每当
class Foo { public: explicit Foo() {} explicit Foo(Foo&) {} }; Foo d = Foo(); error: no matc
是 foo as? Foo完全等同于 foo as Foo? ? 如果是,那为什么两者都有? 如果不是,那么有什么区别? 最佳答案 as?是 safe cast operator . 通常,如果您尝试
关闭。这个问题是opinion-based .它目前不接受答案。 想要改进这个问题? 更新问题,以便 editing this post 可以用事实和引用来回答它. 关闭 9 年前。 Improve
这个问题在这里已经有了答案: Why is there an injected class name? (1 个回答) 关闭5年前。 一位同事不小心写了这样的代码: struct foo { fo
我遇到了这些关键字::foo、::foo、::bar/foo 和 :bar/foo 您能举例说明差异吗? 最佳答案 :foo 是一个非完全限定的关键字。它没有关联的命名空间。 (name :foo)
有人问我如何简化这个 lambda (Foo foo) -> foo.getName() 还有更好的写法吗? 最佳答案 Foo::getName。 假设getName是一个实例方法,其签名中的参数列表
编写此规则集的 CSS 组合器或简写是什么? foo bar, foo biz, foo gaz > boo, foo tar { ... } 我很确定我在 MDN 的某处读到过有一个。是不是: f
我有一个用这个字符串填充的输入文本 "foo foo"但插入后字符串看起来像这样 "foo foo" .我该如何解决?我想以第一种格式显示字符串! 最佳答案 你可能有这样的事情: " /> 更改 va
假设我有一个不可复制类Foo,它的构造函数之一恰好接收到对 Foo 的引用。 class Foo { public: Foo(Foo& parent) {...} private: v
class Artist @@song_count = [] attr_accessor :name, :songs def initialize(name) @name = name
请解释为什么这些 Perl 函数的调用方式在函数定义之上决定了它们是否运行。 print "Why does this bare call to foo not run?\n"; foo; print
文件名分为三种类型 首先( Root 于某种“当前工作目录”之下) ../foo ./foo bar/foo # really in this group? 和( Root 于绝对路径,独立于 CWD
我想自动连接 foo: @Autowired Foo foo 但我无法修改类 Foo 并将其标记为 @Component。 Autowiring foo 最干净的方法是什么? 顺便说一句,如果您需要使
我一直在使用 Python 的 ElementTree 创建 XML 文档,到目前为止一切顺利。然而我现在面临的问题是,由于项目要求,我需要生成一个 XML 文档,其中包含带有开始和结束标签的元素以及
class Foo { public: Foo(){} private: Foo(const Foo &); }; Foo f(); Foo f1 = Foo(); 我发现当我将 Fo
我有一个 jquery 对话框,上面有一个按钮(我的按钮,不是对话框按钮之一)。 设置对话框后,我有以下代码: $('#bar').click(foo('baz')); 当我加载页面并显示对话框时,f
我遇到了以下变量的情况: var foo: Foo | Foo | Foo; 动态生成(使用 keyof 和 stuff),这在代码的那个点是完全有意的。但是,我需要调用像这样定义的对象内部的方法:
clang 3.5.0 和 gcc 4.9.1 从代码生成的可执行文件 #include struct Foo { Foo() { std::cout << "Foo()" << std::e
对于声明为 Foo& foo = ...; 的 foo,lambdas 的按值捕获和按引用捕获语义之间有什么区别吗? 最佳答案 我认为你已经陷入了一个常见的误解......引用是对真实对象的别名。初始
我是一名优秀的程序员,十分优秀!