shyamseshadri / angularjs-up-and-running Goto Github PK
View Code? Open in Web Editor NEWAll the source code for the AngularJS Up & Running Book for O'Reilly
License: MIT License
All the source code for the AngularJS Up & Running Book for O'Reilly
License: MIT License
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.11/angular.js" >
</script>
<script type= "text/javascript" >
angular.module('notesApp', [])
.controller('MainCtrl', [function () {
var self = this ;
self.sports = [
{label: 'Basketball', selected: 'YES'},
{label: 'Cricket', selected: 'NO'},
{label: 'Soccer', selected: 'NO'},
{label: 'Swimming', selected: 'YES'}
];
}]);
</script>
</body>
Using Angular 1.4.4 ng-repeat does not order objects as it did on 1.3.11
Hi, I feel strange of this example...
Why those items return to default when I change the tab?
After clicking the add function, the page's new Item add correctly, but if change the tab, and change back, everything gone! :-o!
ng-switch seems to create new scope every time!
I am new to Angular. Trying to build a sample appilication with VS.NET 2015 using angularjs.
When i try to load my application,I am facing this issue. Appreciate your help.
HTML
<meta name="viewport" content="width=device-width" />
<title></title>
<link href="CSS/amelia.bootstrap.min.css" rel="stylesheet" />
<link href="CSS/Site.css" rel="stylesheet" />
<script src="~/Scripts/angular.js"></script>
<script src="~/Content/app/Controllers/RegistrationController.js"></script>
<script src="~/Content/app/Resources/RegistrationResource.js"></script>
In Body:
Controller.js
var app = angular.module('regApp', ['regApp2']);
app.controller('RegistrationCtrl', ['$scope', function ($scope, rescountries) {
$scope.GetCountries = function () {
var countries = rescountries.GetAllCountries();
countries.$promise.then(function (data) {
$scope.countries = data;
$scope.selectedCountry = 1;
}, function (error) { $scope.RegistrationResource = false });
};
}]);
Service.js
var app = angular.module('regApp2', []);
app.factory('RegistrationResource', ['$http', function ($http) {
var urlBase = 'http://localhost:62463/';
var rescountries = {};
rescountries.GetAllCountries = function () { return $http.get(urlBase + '/api/Registration/GetAllCountries') }
return rescountries;
}]);
Api call
using WebAPIAngular.DAL;
using WebAPIAngular.Entities;
using WebAPIAngular.Models;
using WebAPIAngular.Controllers;
namespace WebAPIAngular.WebAPI
{
[RoutePrefix("api/Registration")]
public class RegistrationController : ApiController
{
// GET api/GetAllStates/{id}
[Route("api/GetAllStates/{id}")]
public IEnumerable GetAllStates(int id)
{
return StateRepository.GetAllStates(id);
}
// GET api/GetAllCountries
[HttpGet]
[Route("api/GetAllCountries")]
public IEnumerable<Country> GetAllCountries()
{
return CountryRepository.GetAllCountries();
}
}
}
Simplify from:
<!-- File: chapter11/directive-broken-reference/stock.html -->
<div class="stock-dash">
Name:
<span class="stock-name"
ng-bind="stockData.name">
</span>
Price:
<span class="stock-price"
ng-bind="stockData.price | currency">
</span>
Percentage Change:
<span class="stock-change"
ng-bind="getChange(stockData) + '%'">
</span>
<button ng-click="changeStock()">
Change Stock in Directive
</button>
</div>
to:
<!-- File: chapter11/directive-broken-reference/stock.html -->
<div>
Name: {{stockData.name}}
Price: {{stockData.price | currency}}
Percentage Change: {{getChange(stockData) + '%'}}
<button ng-click="changeStock()">
Change Stock in Directive
</button>
</div>
I noticed that the source code of chapter11/directive-broken-reference/index.html here is a little more complex than the code on the book (pages 186-187). It has an extra List of Stocks Repeating Manually section:
<h3>List of Stocks Repeating Manually</h3>
<div stock-widget stock-data="mainCtrl.stocks[0]">
</div>
<div stock-widget stock-data="mainCtrl.stocks[1]">
</div>
I am a little confused why when the button in this section is clicked, it will update both List of Stocks Using Repeaters and List of Stocks Repeating Manually. (The book explained why when we click the button in List of Stocks Using Repeaters, the text in List of Stocks Repeating Manually wouldn't be updated.)
Hi,
I appreciate the work done on this book. Anyone can learn angularjs with the help of this book.
I notice one small issue with checkbox example on page 63 Chapter 4: Forms, Inputs and Services.
ng-true-value & ng-false-value should be enclosed with single quotes ("'YES'" and "'NO'")
Wrong :
ng-true-value="YES"
ng-true-value="NO"
Right:
ng-true-value="'YES'"
ng-true-value="'NO'"
I'm reading through AngularJS: Up and Running and am having to reread a lot of the material to follow your examples. I find that the code from example to example changes slightly and I'm having to study the code unnecessarily to see the changes. As a recommendation, I suggest you highlight changes in code, ie:
an easy way to get the examples running (on Linux) is:
install node.js
git clone https://github.com/shyamseshadri/angularjs-up-and-running
cd angularjs-up-and-running
npm init
(accept all defaults)
npm install --save http-server
node node_modules/http-server/bin/http-server
connect browser to localhost:8080
example directory is served
Hello! I am enjoying your book, thank you.
In Chapter 6, I am unclear how method-override is being used in server.js.
I thought perhaps a naive attempt to use $http.delete
wouldn't work without it, but that doesn't appear to be the case: I made a test branch at https://github.com/amacleay/angularjs-up-and-running/tree/delete-example with such a naive implementation and it seems to work fine:
cd $(mktemp -d);git clone https://github.com/amacleay/angularjs-up-and-running; cd angularjs-up-and-running
)git checkout delete-example; npm i; npm start
)I'm just curious what method-override does in this example. Hopefully it's not explained in the next chapter or I'll feel foolish!
Chrome 43.0.2357 (Mac OS X 10.10.3) MainCtrl Server Calls should load items from server FAILED
TypeError: e.cookies is not a function
at n (Sites/sandbox/gitHub_basics/angular/angular.min.js:82:350) ...
Not sure why this error is happening, copied and pasted the example from gitHub and still get it :/
chapter 8 filter-arrays.html example done filter not working.
When running the test the expect fails with the following message:
Expected '' to equal '100; 200;Best Stock'.
I am running against AngularJS 1.3.
I think this should be this.goodbyeMsg = 'Goodbye ';
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.