Created
February 16, 2016 13:07
-
-
Save dshster/5374dffbda08e7a427aa to your computer and use it in GitHub Desktop.
Angular bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var application = 'application'; | |
angular.module(application, ['ngMockE2E']); | |
angular.module(application) | |
.controller('SampleController', function(SampleServices) { | |
var Sample = this; | |
SampleServices.getServerData().then(function(result) { | |
Sample.serverData = result; | |
}, function(error) { | |
Sample.error = error; | |
}); | |
}); | |
angular.module(application) | |
.factory('SampleServices', function($q, $http) { | |
var SampleServices = { | |
getServerData: function() { | |
return $q(function(resolve, reject) { | |
$http({ | |
method: 'GET', | |
url: '/api/sample' | |
}).success(resolve).error(reject); | |
}); | |
} | |
}; | |
return SampleServices; | |
}); | |
angular.module(application) | |
.run(function($httpBackend) { | |
$httpBackend.whenGET(new RegExp('/api/sample')).respond(function(method, url, data) { | |
return [200, {data: {foo: 'bar'}}]; | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "Angular1", | |
"authors": [ | |
"Dmitry Shvalyov <[email protected]>" | |
], | |
"description": "", | |
"main": "", | |
"moduleType": [], | |
"license": "MIT", | |
"homepage": "", | |
"ignore": [ | |
"**/.*", | |
"node_modules", | |
"bower_components", | |
"test", | |
"tests" | |
], | |
"dependencies": { | |
"angular-mocks": "^1.5.0", | |
"angular": "^1.5.0" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="ru"> | |
<head> | |
<meta charset="UTF-8"> | |
<script src="bower_components/angular/angular.min.js"></script> | |
<script src="bower_components/angular-mocks/angular-mocks.js"></script> | |
<script src="application.js"></script> | |
<title>Document</title></head> | |
<body ng-app="application"> | |
<div ng-controller="SampleController as Sample"> | |
{{Sample}} | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment