Skip to content

Instantly share code, notes, and snippets.

developing a tdd tutorial

Juntao Qiu abruzzi

developing a tdd tutorial
View GitHub Profile
abruzzi / simple-log-interceptor.js
Last active January 1, 2016 07:19
How to define a interceptor in AngularJS
View simple-log-interceptor.js
app.factory('MyHTTPInterceptor', function($q) {
return {
// On response success
response: function (response) {
// Return the response or promise.
return response || $q.when(response);
abruzzi / directive-controller-communication.html
Last active January 1, 2016 09:09
directive invoke controller methods
View directive-controller-communication.html
<div ng-app="twitterApp">
<div ng-controller="AppCtrl">
<div enter="deleteTweets()">Roll over to load more tweets</div>
abruzzi / angularjs-resource.txt
Last active October 14, 2019 10:50
angularjs resources
View angularjs-resource.txt
abruzzi / chart.html
Created December 26, 2013 12:18
Define a directive
View chart.html
<highchart value="chartData" type="line" width="800" height="400">
View expander-directive-spec.js
'directives/expander-directive'], function() {
describe("expander directives", function() {
var element, scope;
beforeEach(function() {
inject(function($compile, $rootScope) {
abruzzi / batch-request.cmd
Created December 27, 2013 08:25
batch for loop
View batch-request.cmd
FOR /L %%A in (1, 1, 10) DO (
curl -H "Content-Type:application/json" -H "Accept: application/json" -X POST \
-d @request.json http://host:port/ -v -L \
--cookie "key=value" -i
abruzzi / $q.when.txt
Created December 30, 2013 02:31
What does $q.when do?
View $q.when.txt
Calling $q.when takes a promise or any other type, if it is not a promise then it will wrap it in a promise and call resolve. If you pass a value to it then it is never going to be rejected.
From the docs:
Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
abruzzi / contact-controller.js
Created December 31, 2013 14:25
nested views in angularjs
View contact-controller.js
var app = angular.module('MyApp');
app.controller('ContactController', ['$scope', function($scope) {
$scope.contacts = ["juntao", "abruzzi"];
$scope.submit = function() {
abruzzi / search-setting-controller.js
Created January 2, 2014 08:39
How to mock and test service in angular
View search-setting-controller.js
'services/search-setting-service'], function(controllers) {
['$scope', 'SearchSettingService', function($scope, SearchSettingService) {
SearchSettingService.setting().then(function(setting) {
$scope.setting = setting;
$scope.currentVendor = setting.vendors[0];
abruzzi / index-spec.js
Last active November 19, 2016 08:45
E2E test in AngularJS by using protractor
View index-spec.js
describe("index page", function() {
beforeEach(function() {
it("should have navigator", function() {
it("should have input box", function() {