我正在尝试编写一个单元测试来验证$rootScope.$broadcast('myApiPlay', { action : 'play' });被调用.
这是myapi.js
angular.module('myApp').factory('MyApi', function ($rootScope) {
var api = {};
api.play = function() {
$rootScope.$broadcast('myApiPlay', { action : 'play' });
}
return api;
});
Run Code Online (Sandbox Code Playgroud)
这是我的单元测试:
describe('Service: MyApi', function () {
// load the service's module
beforeEach(module('myApp'));
// instantiate service
var MyApi;
var rootScope;
beforeEach(function () {
inject(function ($rootScope, _MyApi_) {
MyApi = _MyApi_;
rootScope = $rootScope.$new();
})
});
it('should broadcast to play', function () {
spyOn(rootScope, '$broadcast').andCallThrough();
rootScope.$on('myApiPlay', function (event, data) {
expect(data.action).toBe('play'); …Run Code Online (Sandbox Code Playgroud) javascript jasmine angularjs karma-jasmine yeoman-generator-angular
我是yeoman工具的新手.我在Ubuntu 12中运行以下命令
$ npm install -g yo
$ npm install -g generator-webapp
$ yo webapp
Run Code Online (Sandbox Code Playgroud)
我能够创建一个Web应用程序项目.之后我尝试创建一个角度项目.首先我运行一个命令
$ npm install -g generator-angular
Run Code Online (Sandbox Code Playgroud)
安装此发电机时不会显示错误.
当我运行命令
$ yo angular
Run Code Online (Sandbox Code Playgroud)
我收到错误:
Error angular
You don't seem to have a generator with the name angular installed.
You can see available generators with npm search yeoman-generator and then install them with npm install [name].
To see the 2 registered generators run yo with the `--help` option.
Run Code Online (Sandbox Code Playgroud)
怎么解决这个?当我运行命令
$ ls $(npm config get prefix)/lib/node_modules
Run Code Online (Sandbox Code Playgroud)
输出是:
bower generator-angular …Run Code Online (Sandbox Code Playgroud) 撰写问题时使用谷歌翻译.
在新安装的ubuntu 14.04 set nodejs上 -
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install python-software-properties python g++ make nodejs
Run Code Online (Sandbox Code Playgroud)
然后安装哟 -
sudo npm i -g yo
Run Code Online (Sandbox Code Playgroud)
然后我安装发电机角 -
sudo npm i -g generator-angular
Run Code Online (Sandbox Code Playgroud)
从目录中打开终端并安装generator-angular -
yo angular
Run Code Online (Sandbox Code Playgroud)
并得到很多错误.为什么?怎么解决?
Sergio Lopez Mendez - 谢谢你的帮助!
???????? ????? ?? ??????????node_modules
sudo chown -R user:group /usr/lib/node_modules/
sudo chown -R `whoami` ~/.npm
Run Code Online (Sandbox Code Playgroud)
错误几乎消失了,但差不多......
npm WARN package.json mytesttwo@0.0.0 No description
npm WARN package.json mytesttwo@0.0.0 No repository field.
npm WARN package.json mytesttwo@0.0.0 No README …Run Code Online (Sandbox Code Playgroud) javascript npm yeoman yeoman-generator yeoman-generator-angular
运行yo angular然后cd'进入应用程序的根文件夹(与app文件夹相同的级别gruntfile,package.json等)我尝试grunt serve,我得到上述错误.Grunt不会为我启动服务器.
我已经搜遍了所有但是找不到说运行npm install并且bower install在应用程序的根目录中,我已经尝试但仍然是同样的错误.
我已经更新并检查了bower/grunt/npm,它们都很好.
有什么建议吗?
我想使用yeoman生成一个有角度的应用程序结构,但错误阻止了我.
yo-->Angular Bootstrap-->more options-->
发生错误:
Possibly unhandled Template render error: (unknown path) [Line 3, Column 90]
expected variable end
at Object.exports.withPrettyErrors (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/nunjucks/src/lib.js:33:17)
at Obj.extend.render (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/nunjucks/src/environment.js:344:20)
at Obj.extend.renderString (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/nunjucks/src/environment.js:231:21)
at Generator.engine [as _engine] (/usr/lib/node_modules/generator-angular-bootstrap/app/modules/nunjucks-engine.js:17:14)
at Generator.engine (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/yeoman-generator/lib/actions/actions.js:314:10)
at Generator.template (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/yeoman-generator/lib/actions/actions.js:289:15)
at setupAppFiles (/usr/lib/node_modules/generator-angular-bootstrap/app/index.js:209:10)
at tryCatch1 (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/bluebird/js/main/util.js:45:21)
at Promise$_callHandler [as _callHandler] (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/bluebird/js/main/promise.js:658:13)
at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (/usr/lib/node_modules/generator-angular-bootstrap/node_modules/bluebird/js/main/promise.js:672:18)
Run Code Online (Sandbox Code Playgroud)
那么,有人可以帮助我吗?
我有问题使用ui-router与yeoman运行grunt.
如果我跑
咕噜声
该脚本有效
同
咕噜
我有:
Connected on socket um1BuGgogBUojHlvIawT with id 77936474
Chrome 30.0.1599 (Linux) Controller: MainCtrl should attach a list of awesomeThings to the scope FAILED
Error: [$injector:modulerr] Failed to instantiate module browserApp due to:
Error: [$injector:modulerr] Failed to instantiate module ui.router due to:
Error: [$injector:nomod] Module 'ui.router' 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.
http://errors.angularjs.org/1.2.16/$injector/nomod?p0=ui.router …Run Code Online (Sandbox Code Playgroud) 我已经生成了一个角度项目yo angular [project-name],尝试通过它构建它grunt build.我检查了dist/scripts/vendor.d41d8cd9.js文件,我看到它是空的.我发现了这个问题,它根本没有帮助我.如果有人能指出我正确的方向,我将不胜感激.
我正在写这个比较,以帮助人们理解所有这些废话,目前,它看起来像生成器角度的好处和价值是你使用generator-angular-fullstack获得的一部分.我自己填写这些东西,我不是专家,所以很可能充满了可疑的事实.
但它已经被传递了很多,没有人哭过犯规,所以也许这是正确的.如果是这样,那将导致合乎逻辑的结论:人们应该总是使用generator-angular-fullstack并删除后端部分(如果不需要它们).但事实并非如此,因为许多人仍在使用发电机角度.我看到发电机角度 - fullstack是从发电机角度分叉的,但那么呢?
我想我一定错过了什么.发电机角度给人们发电机角度全堆栈没有什么意义?
我正在使用Firebase,AngularFire应用程序创建一个AngularJS,Yeoman堆栈,我使用generator-angularfire(https://github.com/firebase/generator-angularfire)来设置我的simpleLoginTools.我只下载了电子邮件/密码验证,因为验证的唯一要点是我需要一些用户来管理,以便为网站创建新内容并销毁旧内容.但是,当我转到我的'example.com/#/login'并尝试通过电子邮件和密码注册新用户时,它给了我一个
Error: The specified authentication type is not enabled for this Firebase.
Run Code Online (Sandbox Code Playgroud)
是因为我的应用程序/ Firebase数据库中没有用户模型吗?如果是这样,我该怎么做呢?如果不是,我如何通过此错误?
angularjs firebase angularfire yeoman-generator-angular firebasesimplelogin
我按照这些说明为我的应用程序:
https://github.com/yeoman/generator-angular#readme
我的索引(在构建之前)
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css(.) styles/vendor.css -->
<!-- bower:css -->
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css" />
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/app.css -->
<link href="app.less" type="text/css" rel="stylesheet/less">
<!-- endbuild -->
Run Code Online (Sandbox Code Playgroud)
我的dist索引(在文本编辑器中)
<html ng-app="myApp"> <head> <meta charset="utf-8"> <title>Datavalidering</title> <meta name="description" content=""> <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"> <!-- Place favicon.ico and apple-touch-icon.png in the root directory --> <link rel="stylesheet" href="styles/vendor.2ac5f564.css"> <link rel="stylesheet" href="styles/app.d41d8cd9.css"> </head> <body>
Run Code Online (Sandbox Code Playgroud)
Dist索引(浏览器)
<head>
<style type="text/css">@charset "UTF-8";[ng\:cloak],[ng-cloak],[data-ng-cloak],[x-ng-cloak],.ng-cloak,.x-ng-cloak,.ng-hide:not(.ng-hide-animate){display:none …Run Code Online (Sandbox Code Playgroud) angularjs ×6
yeoman ×6
javascript ×3
npm ×2
angularfire ×1
bower ×1
firebase ×1
gruntjs ×1
jasmine ×1
node.js ×1