From 498f24c5c58e70fb17dfd65edb549b440707d086 Mon Sep 17 00:00:00 2001 From: Nicholas Eduardo Date: Mon, 11 May 2015 14:31:20 -0300 Subject: [PATCH] add service and directive in file angularjs.md --- angularjs.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/angularjs.md b/angularjs.md index 941dfe95d..63e56325d 100644 --- a/angularjs.md +++ b/angularjs.md @@ -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: '

Hello

' + } + }); + +In HTML will use to render your template

Hello

### HTTP