spbooks / angularjs1 Goto Github PK
View Code? Open in Web Editor NEWCode archive for the book AngularJS: Novice to Ninja
Code archive for the book AngularJS: Novice to Ninja
Im having problem passing the tests;
I always get the same on the console:
"FAILED Directive Test Should initialize comments div with 2 comments"
I followed all steps on the book and still, getting this all the time.
I suspect is because -> elem.find('.single-comment').length returns 0; so I think comments are not mocked properly.
Any help in here ?
PS: The book is awesome, but the code... well... would be nice if book and repository match.
I have been trying to post a new comment in my sp-blogger app, however I keep on getting an error, I have tried the official 'Final Codebase' from this sample, but am still getting the same error:
'sh' is not recognized as an internal or external command, operable program or batch file.
Solution?
I'm working through the Angular JS - Novice To Ninja book. In Chapter 2 the book says to download the sample application, but does not tell you how or where. I have to assume this is the location it is talking about. If so, these code examples do not match what is stated in the book. So far I've noticed when trying to work through Chapter 6:
"https://github.com/angular/angularseed/
tree/69c9416c8407fd5806aab3c63916dfcf0522ecbc"
This link, given in the book is giving 404 error. Please give some advice how we can get this.
Hello Sandeep,
I found your book pretty awesome...but i have really hard time following with the code walk through from chapter 6 and on...as i can image many people...I read your answer on billhannah but i am still facing problems...for example ui.router isn't mentioned nor is the bootstrap.css file as it is missing from chapter 2 zip file.
I would love if you could go through the process again and have a more clear walk through for us to follow.
Regards.
Mat
When I run test.bat from the sp-blogger scripts folder i get the following error: it seems like EventEmitter is undefined. Everything works fine if I run test.bat with an older version of node js specifically 6.12.2, but if I try with the LTS latest version (8.9.3) it outputs the following error: what do I need to do to fix this? it seems like something is depreciated with the latest version of node js, probably EventEmitter??? Thanks.
`C:\Users\Yanni\Desktop\angularjs1-master\Ch 02\sp-blogger>scripts\test.bat
C:\Users\Yanni\Desktop\angularjs1-master\Ch 02\sp-blogger\node_modules\karma\node_modules\socket.io\lib\store.js:35
Store.prototype.proto = EventEmitter.prototype;
^
TypeError: Cannot read property 'prototype' of undefined
at Object. (C:\Users\Yanni\Desktop\angularjs1-master\Ch 02\sp-blogger\node_modules\karma\node_modules\socket.io\lib\store.js:35:42)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\Yanni\Desktop\angularjs1-master\Ch 02\sp-blogger\node_modules\karma\node_modules\socket.io\lib\manager.js:16:13) at Module._compile (module.js:635:30)`
I am struggling with the chapter 11 unit tests too, the problem occurs in the line that runs '$rootScope.$digest();', I am getting:
I found the start of Chapter 1 very frustrating because you sit down and are ready to learn Angular and the very first experience is Angular.js not working. After messing around for a while I sorted out why the code included in the book does not work with the latest version of Angular. Hope this helps unblocks other developers jumping into Angular.JS who purchased the book.
While the book could use an update, I recommend validating any of the core method calls here:
https://docs.angularjs.org/guide/
app/test.html
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Finance Meter</title>
<link rel="stylesheet" href="css/app.css"/>
</head>
<body ng-controller="FinanceController">
Your Salary?
<input type="text" ng-model="salary">
<br/>How much should you invest in shopping?
<input type="text" ng-model="percentage">%
<br/>The amount to be spent on gadgets will be: <span>{{result()}}</span>
<!-- In production use:
<script src="//ajax.googleapis.com/ajax/libs/angularjs/x.x.x/angular.min.js"></script>
-->
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
</body>
</html>
app/js/app.js
'use strict';
// Declare app level module which depends on filters, and services
angular.module('myApp', [
'myApp.controllers'
]);
app/js/controllers.js
angular.module('myApp.controllers', []).
controller('FinanceController', ['$scope', function($scope) {
$scope.salary = 0;
$scope.percentage = 0;
$scope.result = function() {
return $scope.salary * $scope.percentage * 0.01;
};
}]);
Sorry for another noob question, but I can't get the unit tests from chapter 9 to pass, it seems the problem occurs when calling '$httpBackend.flush();', I even tried copying across the unit test from the final codebase sample (remembering to comment out the 'afterEach' blocks), but still get the same error:
$scope.post.$update is not a function
Facing this error while doing code from chapter 6. All the code is same as chapter 6. Please let me know if someone solve this.
hi
when I type node ../scripts/web-server.js . the console show:
" GET http://spblogger-sitepointdemos.rhcloud.com/api/posts (index):1
XMLHttpRequest cannot load http://spblogger-sitepointdemos.rhcloud.com/api/posts. No 'Access-Control-Allow-Origin' header is present on the requested resource.
how can I do ?
I was wondering why both angular-loader.js and script.js are required ?
I have been playing with the exercises from chapter 9, I get read and update data in the rhcloud spBlogger API, but I can't seem to be allowed to delete or create new entries, am I doing something wrong? Or is the API protected against delete and post verbs?
I've downloaded the code and made the updates according to the book (Chapter 6) and I get this error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module spBlogger due to:
Error: [$injector:modulerr] Failed to instantiate module spBlogger.posts due to:
Error: [$injector:unpr] Unknown provider: $stateProvider
http://errors.angularjs.org/1.3.0-beta.2/$injector/unpr?p0=%24stateProvider
at http://localhost:8000/lib/angular/angular.js:78:12
at http://localhost:8000/lib/angular/angular.js:3596:19
at getService (http://localhost:8000/lib/angular/angular.js:3723:39)
at Object.invoke (http://localhost:8000/lib/angular/angular.js:3750:13)
at http://localhost:8000/lib/angular/angular.js:3679:37
at Array.forEach (native)
at forEach (http://localhost:8000/lib/angular/angular.js:322:11)
at loadModules (http://localhost:8000/lib/angular/angular.js:3666:5)
at http://localhost:8000/lib/angular/angular.js:3673:40
at Array.forEach (native)
http://errors.angularjs.org/1.3.0-beta.2/$injector/modulerr?p0=spBlogger.po…ngular%2Fangular.js%3A3673%3A40%0A%20%20%20%20at%20Array.forEach%20(native)
at http://localhost:8000/lib/angular/angular.js:78:12
at http://localhost:8000/lib/angular/angular.js:3700:15
at Array.forEach (native)
at forEach (http://localhost:8000/lib/angular/angular.js:322:11)
at loadModules (http://localhost:8000/lib/angular/angular.js:3666:5)
at http://localhost:8000/lib/angular/angular.js:3673:40
at Array.forEach (native)
at forEach (http://localhost:8000/lib/angular/angular.js:322:11)
at loadModules (http://localhost:8000/lib/angular/angular.js:3666:5)
at createInjector (http://localhost:8000/lib/angular/angular.js:3606:11)
$stateProvider is set in app/modules/postModule.js
Can somebody help me figure out where I went off the rails?
I am also getting this error if I try to import the templates module in the unit test for chapter 11
Hi there, great book, however, I am not being able to run the last set of unit tests from page 124, in the PostDetailsController test, the 'it' part of the test injects $state and $stateParams, for some reason, the $stateParam can be injected correctly, however, the $state cannot, I triple checked and angular ui is present in my karma.conf and in my beforeEach()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.