shyamseshadri / angularjs-book Goto Github PK
View Code? Open in Web Editor NEWExamples and Code snippets from the first AngularJS O'Reilly book which is now heavily out of date!
Examples and Code snippets from the first AngularJS O'Reilly book which is now heavily out of date!
test issues
According to this
Rawgithub.com allows users to take the "Raw" versions of a Git and turn it into a URL usable in <script> tags.
Use raw.github
will get this error.
Refused to execute script from 'http://raw.github.com/blueimp/jQuery-File-Upload/master/js/vendor/jquery.ui.widget.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
sortByDuration compares duration as strings and as a result the sorted order ends up 17:45
3:21
5:34
Hello
I want use Karma. I installed it and run in sample-app root file.
Karma ask for "What is the location of your source and test files ?"
so which directory for test ?
test directory or test/spec directory ?
Hello, I'm one of the readers of this book. I found that the template viewRecipe.html on page 92 was not correspond with the text content. For example, there is no ng-class in the code, which is mentioned in the text content.
I think most of the readers use express 4.0 nowadays.As we know, bodyParser and method-override have been deprecated, so It's better to update these codes in order to provide better guidance for the green hands.
When I go to http://localhost:9000/, I see
Loading....
New Recipe
Recipe List
In the console there is the error
Failed to load resource: the server responded with a status of 404 (Not Found)
I click on New Recipe and am able to fill out the form, but when I click on Save, I get:
POST http://localhost:9000/recipes 404 (Not Found)
Stack trace is below if that is meaningful to you.... would love to run this sample app - seems pretty important in understanding Angular.
Thanks in advance for any advice...
RB
GET http://localhost:9000/recipes 404 (Not Found) angular.min.js:96
(anonymous function) angular.min.js:96
o angular.min.js:93
l angular.min.js:92
g.(anonymous function) angular-resource.min.js:8
(anonymous function) services.js:15
$routeProvider.when.resolve.recipes controllers.js:12
d angular.min.js:26
(anonymous function) angular.min.js:79
m angular.min.js:6
e.when.then.then.b.locals angular.min.js:79
i angular.min.js:75
i angular.min.js:75
(anonymous function) angular.min.js:76
e.$eval angular.min.js:86
e.$digest angular.min.js:84
e.$apply angular.min.js:86
(anonymous function) angular.min.js:15
d angular.min.js:26
qb angular.min.js:15
jc angular.min.js:15
(anonymous function) angular.min.js:159
a angular.min.js:114
(anonymous function) angular.min.js:22
m angular.min.js:6
c
I cannot get this to work. I run 'grunt serve' (grunt server is deprecated) I get 'fatal error, bower components not found'.
Any help is appreciated.
hi,I use ng1.3.0 write the demo of https://github.com/shyamseshadri/angularjs-book/blob/master/chapter2/formValidation.html
but the age valid is not work
when I use 1.0.8 ng-min not work, age < 1 still can submit
Can I use angular without any tools such as karma,yoeman or something else ?
And anybody can tell me about what phantomjs exactly do ?
For beginners it is probably unclear how to serve these files, especially if skipping around in the book. The readme should have links to installing node, using NPM install and running a node web server.
The example is not working with Angular 1.2.15. Giving "Uncaught object" at line :78 in angularjs.
Shouldn't there be 'ng-show="recipe.id"' (instead of 'ng-show="!recipe.id"' , because "Delete" button should be visible on "Edit", not "Add"
the $index in the remove function ,which cannot define as the current index in the ng-repeat array. In the console, when i try to find out the current index, it show undefined.
why?
js:
var myApp=angular.module('app1',[]);
myApp.factory('Data', function(){//this is the set up ofthe service.
items=[
{id:0, name:'pen', quality:20, unitPrice:2.20},
{id:1, name:'paper', quality:17, unitPrice:1.20},
{id:2, name:'sticker', quality:40, unitPrice:0.10},
]
return items;
})
myApp.controller('Ctrl_1', function($scope, Data){
$scope.items=Data;
$scope.createNewItem=function (a,b,c){
var index=$scope.items.length;
index=index++;
a=$scope.name;
b=$scope.quality;
c=$scope.unitPrice;
$scope.items.push( {id:index, name:a, quality:b, unitPrice:c});
}
$scope.remove = function(index ){
console.log($scope.items);
console.log(index);//in concoel show it undefined.
$scope.items.splice(index, 1);
console.log($scope.items);
}
})
myApp.controller('Ctrl_2',function($scope, Data){
$scope.items=Data;
});
html:
<!doctype html>
Quantity: {{item.quality}}
Unit Price: {{item.unitPrice}}
Total: {{item.unitPrice*item.quality | currency}}
</div>
Imports System.Data.OleDb
Public Class frm_class
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Try
If txtClassNumber.Text = "" Then
MsgBox("Fadlan ku qor numberka classka ")
txtClassNumber.Focus()
Exit Sub
End If
If txtNumberofTables.Text = "" Then
MsgBox("Fadlan ku qor Tirada miisaska")
txtNumberofTables.Focus()
Exit Sub
End If
If txtNumberofChairs.Text = "" Then
MsgBox("Fadlan ku qor Tirada kuraasta")
txtNumberofChairs.Focus()
Exit Sub
End If
con = New OleDbConnection(cs)
con.Open()
Dim cb As String = "insert into [class] VALUES (" & txtClassNumber.Text & ",'" & txtNumberofTables.Text & "','" & txtNumberofChairs.Text & "')"
cmd = New OleDbCommand(cb)
cmd.Connection = con
cmd.ExecuteReader()
MessageBox.Show("Saved Successfully", "Record", MessageBoxButtons.OK, MessageBoxIcon.Information)
Reset()
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
Reset()
End Sub
Sub Reset()
txtClassNumber.Text = ""
txtNumberofTables.Text = ""
txtNumberofChairs.Text = ""
txtClassNumber.Focus()
End Sub
Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
End
End Sub
End Class
For a live demo of the bug go to here.
In the mode, I have assigned an initial value to currentDate
:
$scope.currentDate = '01/02/2020';
Now when you select a date via the data picker, currentDate
is not changing anymore.
To expand, the issue seems to be that the binding more or less behaves unidirectional: when the model is changed by code external to the date picker component, the date picker is not re-rendering itself.
how can i read this code?
Amail application not working in chapter 2.
What should be problem ?
这个还是很好的一个代码的
current github code:
describe('MultiRecipeLoader', function() {
var mockBackend, recipe, loader;
// The _$httpBackend_ is the same as $httpBackend. Only written this way to
// differentiate between injected variables and local variables
beforeEach(inject(function(_$httpBackend_, Recipe, MultiRecipeLoader) {
recipe = Recipe;
mockBackend = _$httpBackend_;
loader = MultiRecipeLoader;
}));
it('should load list of recipes', function() {
mockBackend.expectGET('/recipes').respond([{id: 1}, {id: 2}]);
var recipes;
var promise = loader();
promise.then(function(rec) {
recipes = rec;
});
expect(recipes).toBeUndefined();
mockBackend.flush();
expect(recipes).toEqualData([{id: 1}, {id: 2}]);
});
});
my suggestion would be: (this is wrapped in a services test suite where the Recipe resource and $httpBackend mock are scoped for all individual service test suites)
var Recipe,
$httpBackend;
describe('MultiRecipeLoader', function(){
var MultiRecipeLoader;
//injector will ignore front and trailing underscore, this notation is to clarify injected variables
//yet give the ability to write tests using variables exactly the same way the actual implementations do
beforeEach(inject(function (_$httpBackend_, _Recipe_, _MultiRecipeLoader_) {
Recipe = _Recipe_;
$httpBackend = _$httpBackend_;
MultiRecipeLoader = _MultiRecipeLoader_;
}));
it('should load a list of recipes', function () {
$httpBackend.expectGET('/recipes').respond([{id:1}, {id:2}]);
var recipes;
var promise = MultiRecipeLoader;
promise.then(function(rec){
recipes = rec;
});
expect(recipes).toBeUndefined();
$httpBackend.flush();
expect(recipes).toEqualData([{id:1},{id:2}]);
});
after i download the aMail, it can't run as expected.
the error is below:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.9/$injector/modulerr?p0=AMail&p1=Error%3A%2…2F1.2.9%2F%24injector%2Funpr%3Fp0%3D%2524routeProvider%0A%20%20%20%20at%20......2)
the error http://localhost/receipts not found.
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.