我刚刚开始学习Angular.js,我一直在Angular主页上的"连接后端"示例中查看project.js.
我对控制器功能中的参数感到困惑:
function ListCtrl($scope, Projects) {
...
}
function CreateCtrl($scope, $location, $timeout, Projects) {
...
}
function EditCtrl($scope, $location, $routeParams, angularFire, fbURL) {
angularFire(fbURL + $routeParams.projectId, $scope, 'remote', {}).
then(function() {
...
});
}
Run Code Online (Sandbox Code Playgroud)
这些控制器函数在routeProvider中调用,但没有给出任何参数.
$routeProvider.
when('/', {controller:ListCtrl, templateUrl:'list.html'}).
when('/edit/:projectId', {controller:EditCtrl, templateUrl:'detail.html'}).
when('/new', {controller:CreateCtrl, templateUrl:'detail.html'}).
otherwise({redirectTo:'/'});
});
Run Code Online (Sandbox Code Playgroud)
我能找到到目前为止,这可能是唯一的解释发生了什么事情是"注入服务整合到控制器",这说明$location,$timeout而不是参数的方法angularFire和fbURL.
我的具体问题是:
控制器参数可以是什么?
用参数调用控制器函数在哪里?或者参数没有被调用,但只是与控制器相关联的东西,其中关联发生了很多Angular.js魔法(如果是这样,我可以在github上看到源代码)吗?
在哪里angularFire定义?
fbURL参数如何链接到:
angular.module('project', ['firebase']).
value('fbURL', 'https://angularjs-projects.firebaseio.com/').
factory ...
Run Code Online (Sandbox Code Playgroud)有一个地方,我可以看到所有的服务,如$location和$timeout …
我有一个仅命令行的Ubuntu 11.04(GNU/Linux 2.6.35.4-rscloud x86_64),我正在使用Angular Phonecat教程,该教程使用Karma进行测试.该噶浏览器配置页说Chrome启动的是"默认附带噶."
但这对我不起作用.这是karma.conf.js.以下是输出.
$ ./scripts/test.sh
Starting Karma Server (http://karma-runner.github.io)
-------------------------------------------------------------------
INFO [karma]: Karma v0.10.4 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [launcher]: Cannot start Chrome
Can not find the binary google-chrome
Please set env variable CHROME_BIN
Run Code Online (Sandbox Code Playgroud)
这个答案指出我需要铬.
因此,我尝试使用本指南 "使用命令行下载64位版本" 在我的Ubuntu上安装Chrome .一切顺利,直到sudo apt-get -f install最后有很多"无法从ubuntu IP地址获取",例如91.189.91.15或91.189.92..即使使用/ usr/bin/google "无法找到二进制google-chrome"的东西消失了,我仍然在单个测试级别上获得了"无法启动Chrome".然后试图修正错误,我删除的/ usr/bin中/谷歌的东西.
目前,我有这些node_modules:
angular-phonecat/node_modules$ ls
karma karma-html2js-preprocessor karma-requirejs
karma-chrome-launcher karma-jasmine karma-script-launcher
karma-coffee-preprocessor karma-junit-reporter …Run Code Online (Sandbox Code Playgroud) http://myipaddress:3000在我尝试安装MEAN堆栈后,当我去的时候,我得到了这些304和404
$ node server
Express app started on port 3000
GET / 304 973ms
GET /lib/bootstrap/js/bootstrap.js 404 371ms
GET /lib/bootstrap/css/bootstrap.css 404 489ms
GET /lib/angular/angular.js 404 371ms
GET /lib/jquery/jquery.js 404 447ms
GET /lib/bootstrap/css/bootstrap-responsive.css 404 453ms
GET /lib/angular-cookies/angular-cookies.js 404 75ms
GET /lib/angular-resource/angular-resource.js 404 217ms
GET /lib/angular-ui-utils/modules/route.js 404 217ms
GET /lib/angular-bootstrap/ui-bootstrap-tpls.js 404 221ms
Run Code Online (Sandbox Code Playgroud)
所有这些lib/*文件都可以在public/lib/*中找到.
我在Ubuntu上并执行了以下命令:
1. wget https://codeload.github.com/linnovate/mean/legacy.tar.gz/master -O mean
2. tar -zxvf mean
3. npm install
4. sudo npm install -g bower
5. bower install
Run Code Online (Sandbox Code Playgroud)
其中第4步和第5步来自此评论.因为我甚至在第3步之后就得到了错误.
由于人们也提到了 …
我有git版本1.7.4.1.并希望升级到1.8.4的最新稳定版本.
所以我试着sudo apt-get install git在Linux的git下载页面上说,但我得到了这个结果:
Reading package lists... Done
Building dependency tree
Reading state information... Done
git is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 91 not upgraded.
$ git --version
git version 1.7.4.1
Run Code Online (Sandbox Code Playgroud)
我坚持使用git版本1.7.4.1!
我在Ubuntu 11.04上.
在哪个 MEAN 堆栈级别加载批量数据最好?我有大约 200 - 800 个 2 - 3 种不同类型的条目(即它们需要 2 - 3 种不同的猫鼬模式)。
以下是加载这些数据的选项(请随时指出任何误解,我是新手):
mongoimport -d db_name -c collection_name --jsonArray --file jsonfilename.json第三种方式是最纯粹的,也许是最快的,但我不知道在这么低的水平上做是否好。
哪一个是最好的?如果没有最佳选择,那么每种选择的优缺点是什么?