Skip to content

Commit

Permalink
add service and directive in file angularjs.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasess committed May 11, 2015
1 parent f0bcb06 commit 498f24c
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions angularjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ layout: default
($scope, $http) ->
]

### Service

App.factory('NameService', function($http){
return {
get: function(){
return $http.get(url);
}
}
});

In controller you call with parameter and will use promises to return data from server.

App.controller('controllerName',
function(NameService){
NameService.get()
.then(function(){})
})

### Directive

App.directive('name', function(){
return {
template: '<h1>Hello</h1>'
}
});

In HTML will use <name></name> to render your template <h1>Hello</h1>

### HTTP

Expand Down

0 comments on commit 498f24c

Please sign in to comment.