Last active
August 29, 2015 14:14
-
-
Save kanitw/15256571933310366d00 to your computer and use it in GitHub Desktop.
angular directive template
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
'use strict'; | |
angular.module('__appname__') | |
.controller('__controller__Ctrl', function ($scope) { | |
$scope.awesomeThings = [ | |
'HTML5 Boilerplate', | |
'AngularJS', | |
'Karma' | |
]; | |
}); |
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
'use strict'; | |
describe('Controller: __controller__Ctrl', function () { | |
// load the controller's module | |
beforeEach(module('__appname__')); | |
var __controller__Ctrl, | |
scope; | |
// Initialize the controller and a mock scope | |
beforeEach(inject(function ($controller, $rootScope) { | |
scope = $rootScope.$new(); | |
__controller__Ctrl = $controller('__controller__Ctrl', { | |
$scope: scope | |
}); | |
})); | |
it('should attach a list of awesomeThings to the scope', function () { | |
expect(scope.awesomeThings.length).to.be.eql(3); | |
}); | |
}); |
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
'use strict'; | |
/** | |
* @ngdoc directive | |
* @name __appname__.directive:__directive__ | |
* @description | |
* # __directive__ | |
*/ | |
angular.module('__appname__') | |
.directive('__directive__', function () { | |
return { | |
templateUrl: '__component_dir____directive_lower__/__directive_lower__.html', | |
restrict: 'E', | |
replace: true, | |
scope: {}, | |
link: function postLink(scope, element, attrs) { | |
element.text('this is the __directive__ directive'); | |
} | |
}; | |
}); |
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
'use strict'; | |
describe('Directive: __directive__', function () { | |
// load the directive's module | |
beforeEach(module('__appname__')); | |
var element, scope, $compile; | |
beforeEach(inject(function ($rootScope, _$compile_) { | |
scope = $rootScope.$new(); | |
$compile = _$compile_; | |
})); | |
it('should make hidden element visible', function () { | |
element = angular.element('<__directive_dash__></__directive_dash__>'); | |
element = $compile(element)(scope); | |
expect(element.text()).to.be.eql('this is the __directive__ directive'); | |
}); | |
}); |
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
'use strict'; | |
/** | |
* @ngdoc service | |
* @name __appname__.__factory__ | |
* @description | |
* # __factory__ | |
* Factory in the __appname__. | |
*/ | |
angular.module('__appname__') | |
.factory('__factory__', function () { | |
// Service logic | |
// ... | |
var meaningOfLife = 42; | |
// Public API here | |
return { | |
someMethod: function () { | |
return meaningOfLife; | |
} | |
}; | |
}); |
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
'use strict'; | |
describe('Service: __factory__', function () { | |
// load the service's module | |
beforeEach(module('__appname__')); | |
// instantiate service | |
var __factory__; | |
beforeEach(inject(function (___factory___) { | |
__factory__ = ___factory___; | |
})); | |
it('should do something', function () { | |
expect(!!__factory__).to.be.eql(true); | |
}); | |
}); |
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
'use strict'; | |
/** | |
* @ngdoc filter | |
* @name __appname__.filter:__filter__ | |
* @function | |
* @description | |
* # __filter__ | |
* Filter in the __appname__. | |
*/ | |
angular.module('__appname__') | |
.filter('__filter__', function () { | |
return function (input) { | |
return '__filter__ filter: ' + input; | |
}; | |
}); |
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
'use strict'; | |
describe('Filter: __filter__', function () { | |
// load the filter's module | |
beforeEach(module('__appname__')); | |
// initialize a new instance of the filter before each test | |
var __filter__; | |
beforeEach(inject(function ($filter) { | |
__filter__ = $filter('__filter__'); | |
})); | |
it('should return the input prefixed with "__filter__ filter:"', function () { | |
var text = 'angularjs'; | |
expect(__filter__(text)).to.be.eql('__filter__ filter: ' + text); | |
}); | |
}); |
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
'use strict'; | |
/** | |
* @ngdoc service | |
* @name __appname__.__service__ | |
* @description | |
* # __service__ | |
* Service in the __appname__. | |
*/ | |
angular.module('__appname__') | |
.service('__service__', function () { | |
// AngularJS will instantiate a singleton by calling "new" on this function | |
}); |
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
'use strict'; | |
describe('Service: __service__', function () { | |
// load the service's module | |
beforeEach(module('__appname__')); | |
// instantiate service | |
var __service__; | |
beforeEach(inject(function (___service___) { | |
__service__ = ___service___; | |
})); | |
it('should do something', function () { | |
expect(__service__).to.be.eql(true); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment