Skip to content

Commit d8e87be

Browse files
committed
Updated README.md
Fixed some typos, modified some code examples
1 parent 817a137 commit d8e87be

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

README.md

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ There are some *buzzwords* used in AngularJS:
4040
The image summarizes [00-1-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-1-concepts.html)
4141
![Interaction between Controllers-Scope/Model-View](https://docs.angularjs.org/img/guide/concepts-databinding2.png) *image from [AngularJs Docs](https://docs.angularjs.org/guide/concepts)*
4242

43-
- **Services** contain all the 'independant logic', which is other words is a way to supply and manipulate data to our application. We use services to allow us to reuse it in other parts of the application. For example in [00-1-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-1-concepts.html) all the logic was stored within `InvoiceController`. In [00-2-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-2-concepts.html) we will refactor the code to move the conversion logic into a service in another module.
43+
- **Services** contain all the 'independent logic', which is other words is a way to supply and manipulate data to our application. We use services to allow us to reuse it in other parts of the application. For example in [00-1-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-1-concepts.html) all the logic was stored within `InvoiceController`. In [00-2-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-2-concepts.html) we will refactor the code to move the conversion logic into a service in another module.
4444

4545
- **Dependency Injection** In [00-2-concepts.html](https://github.com/zafarali/learning-angular/blob/master/00-2-concepts.html) we see that `ng-app` defines `invoice-srv-demo` as the main module to use in application. In the defintiion of this module we state that `finance` is a dependency of the main module. We also define the constructor for the controller after passing in the dependency `currencyConverter` from the finance module. This is known as *dependency injection*
4646

@@ -114,19 +114,13 @@ We can compare the two using our shopping cart app in [this commit](https://gith
114114
The docs page regarding [forms](https://docs.angularjs.org/guide/forms) we find a whole load of neat tricks and tips that are demonstrated in [01-01-forms.html](https://github.com/zafarali/learning-angular/blob/master/01-1-forms.html). The page also demonstrates the abilities of `ng-show`, `ng-hide`, and validation techniques that AngularJS provides.
115115
###02-Filters
116116
####Custom filters
117-
There's only syntax to learn here, watch this [video](http://www.thinkster.io/angularjs/EnA7rkqH82/angularjs-filters) and see the ( dummy code I [typed](https://github.com/zafarali/learning-angular/blob/master/02-1-filters.html) up. Another example is shown below using extra arguments that can be used as `text|decimal2binary:true`:
117+
There's only syntax to learn here, watch this [video](http://www.thinkster.io/angularjs/EnA7rkqH82/angularjs-filters) and see the dummy code I [typed](https://github.com/zafarali/learning-angular/blob/master/02-1-filters.html) up. Another example is shown below using extra arguments that can be used as `text|decimal2binary:true`:
118118
```javascript
119-
//converts decimals to binary form (i don't think this really works)
119+
//converts decimal to binary string
120120
app.filter('decimal2binary', function(){
121121
function convert(num,bool){
122-
if(bool){ console.log("you said true as argument!");}
123-
num = parseInt(num);
124-
if(num === 0){
125-
return 1;
126-
}else{
127-
remainder = num % 2;
128-
return convert(num/2)+""+remainder;
129-
}
122+
if(bool) { console.log('You specified true'); }
123+
return parseInt(num,10).toString(2);
130124
}
131125
return function(input, bool){
132126
return convert(input, bool);
@@ -262,7 +256,7 @@ app.controller("Ctrl", function($scope){
262256
return $scope.Ctrl = this;
263257
});
264258
```
265-
We can acess this now using the following html:`<div ng-click="Ctrl.sayHi()">Click</div>`. This serves to make the controller explicit and closely mimics the `Controller as` syntax above.
259+
We can access this now using the following html:`<div ng-click="Ctrl.sayHi()">Click</div>`. This serves to make the controller explicit and closely mimics the `Controller as` syntax above.
266260
* Organization. We can organize and initialize our controllers and directives like this. (however this doesn't work for filters)
267261
```javascript
268262
var app = angular.module('myApp', []);
@@ -301,7 +295,7 @@ Now assume we have a `ng-model` input to allow the user to type in the `username
301295
`$watch` can also watch functions to monitor their return function. The `deepWatch` parameter is a boolean. If set to true and an array of objects is passed into the `toWatch` parameter, each property of the object will be checked for changes.
302296

303297
#### Angular Classes
304-
Angular automatically adds classes to some elements depending on how its being used. Here are some use cases:
298+
Angular automatically adds classes to some elements depending on how it's being used. Here are some use cases:
305299
* `ng-invalid`/`ng-valid` will be on an input element depending on if the text inside has passed validation or not
306300
* `ng-pristine`/`ng-dirty` - if the user hasn't interacted with an input element it will have the class of `ng-pristine` and if it has been interacted with it will be `ng-dirty`.
307301
* `ng-binding` is given to any element that has data binding on it.
@@ -320,7 +314,7 @@ A few quick tip:
320314

321315
### 06-Template
322316
Templates are an easy way of making your code very organized. [06-0-templateurl.html](https://github.com/zafarali/learning-angular/blob/master/06-0-templateurl.html) demonstrates how to link a partial file into the main view using the `templateUrl` property of a directive. Note that to use `templateUrl` we must have our files on a server. We can use `$templateCache` to load strings of html into the cache to mimic this effect if we do not have a seperate .html file. We then execute it using `app.run()` function.
323-
We can retrieve whats on `$templateCache` using the `get` function and we can insert things into it using the `put` function as seen in the example at [06-1-templatecache.html](https://github.com/zafarali/learning-angular/blob/master/06-1-templatecache.html)
317+
We can retrieve what's on `$templateCache` using the `get` function and we can insert things into it using the `put` function as seen in the example at [06-1-templatecache.html](https://github.com/zafarali/learning-angular/blob/master/06-1-templatecache.html)
324318

325319
### 07-Routing
326320
*This section requires you to have a server running, this can be easily executed by the bash command `php -S localhost:8080` on a Mac terminal*
@@ -355,7 +349,7 @@ app.config(['$routeProvider', function($routeProvider){
355349
//this returns the correct template for the blog, either MyAmazingBlog or ExtraBlogStuff, if not specified it will move onto //the next .when()
356350
templateUrl:function(routeParams){
357351
return routeParams.blogname+'.html'; },
358-
controler:'BlogCtrl'
352+
controller:'BlogCtrl'
359353
})
360354
.when('/blog/:blogpost', {
361355
//here we direct our older linked users to the new blog
@@ -365,7 +359,7 @@ app.config(['$routeProvider', function($routeProvider){
365359
}]);
366360
```
367361
I hope this example clearly demonstrates a use case and how to for using the '$routeParams' and '$routeProvider' objects correctly.
368-
*Note: We can other parameters we can pass into the functions within route provider are as follows:*
362+
*Note: The other parameters we can pass into the functions within route provider are as follows:*
369363
```javascript
370364
function(routeParams, path, search){
371365
//routeParams as we have seen above
@@ -542,12 +536,12 @@ scope.$emit('myEventName', 'Hello', 'World');
542536
//or
543537
scope.$broadcast('myEventName', 'Bye', 'World');
544538
```
545-
What is the difference between `$emit` and `$broadcast`? As mentioned previously `$emit` propogates the event upwards and all controllers listening for `myEventName` in the parent scopes will be alerted. `$broadcast` does the opposite and propogates the event downwards. Note that both these events will also execute in their own scopes.
539+
What is the difference between `$emit` and `$broadcast`? As mentioned previously `$emit` propogates the event upwards and all controllers listening for `myEventName` in the parent scopes will be alerted. `$broadcast` does the opposite and propagates the event downwards. Note that both these events will also execute in their own scopes.
546540

547541
A new example here [08-2-onEmitBroadcast.html](https://github.com/zafarali/learning-angular/blob/master/08-2-onEmitBroadcast.html) demonstrates this. Remember that declaring a new controller automatically creates a new scope. The page is also demonstrates inherited scopes and overriding properties.
548542

549543
### Forms
550-
*Content from this section (Forms) is based of the course [Shaping Up With AngularJS](http://campus.codeschool.com/courses/shaping-up-with-angular-js/)*
544+
*Content from this section (Forms) is based off the course [Shaping Up With AngularJS](http://campus.codeschool.com/courses/shaping-up-with-angular-js/)*
551545
Remember when we discussed [Angluar Classes above](https://github.com/zafarali/learning-angular#angular-classes)? AngluarJS provides us with a couple of other nice tricks and features that make form validations easier. Let's look at each of them step by step and then do an example:
552546
- `ng-submit` is an attribute of the `<form>` element that has the function will be invoked when the user clicks the 'submit' button. Alternatively this function can also be in `ng-click` of the `<button>` element.
553547
- `formname.$valid` is an object available on the global scope where formname is the `name` attribute of the `<form>` element. From this we can see that AngluarJS does alot behind the scene for us and will automatically validate the form. Returns `true` or `false`.

0 commit comments

Comments
 (0)