Last active
August 29, 2015 14:13
-
-
Save cognitom/d07d231b28d2e9e7bd10 to your computer and use it in GitHub Desktop.
CommonJSフレンドリーな、Angularアノテーション ref: http://qiita.com/cognitom/items/c7b4ffcd26f87b66af8a
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
// インジェクション方法 A | |
$injector.invoke(function(serviceA){}); |
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
// インジェクション方法 B | |
$injector.invoke(['serviceA', function(serviceA){}]); |
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
// app.js | |
angular.module('app', []) | |
.controller('mainCtrl', require('./mainCtrl')); |
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
// mainCtrl.js | |
module.exports = [ | |
'$scope', '$location', '$filter', | |
function ($scope, $location, $filter) { | |
// some angular code | |
} | |
] |
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
// @ngInject | |
module.exports = function ($scope, $location, $filter) { | |
// some angular code | |
} |
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
gulp = require 'gulp' | |
browserify = require 'browserify' | |
ngannotate = require 'browserify-ngannotate' | |
source = require 'vinyl-source-stream' | |
buffer = require 'vinyl-buffer' | |
streamify = require 'gulp-streamify' | |
uglify = require 'gulp-uglify' | |
sourcemaps = require 'gulp-sourcemaps' | |
path = require 'path' | |
$ = | |
src: './src/ng/app.js' | |
dist: './public/js/' | |
gulp.task 'browserify', -> | |
browserify | |
entries: [$.src] | |
.transform ngannotate | |
.bundle() | |
.pipe source path.basename $.src | |
.pipe buffer() | |
.pipe sourcemaps.init loadMaps: true | |
.pipe streamify uglify() | |
.pipe sourcemaps.write './' | |
.pipe gulp.dest $.dist |
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
// app.js | |
angular.module('app', []) | |
.controller('mainCtrl', require('./mainCtrl')); |
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
// mainCtrl.js | |
var inject = require('ng-injector'); | |
inject('$scope'); | |
inject('$location'); | |
inject('$filter'); | |
module.exports = inject(function ($scope, $location, $filter) { | |
// some angular code | |
}); |
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
// mainCtrl.js | |
var inject = require('ng-injector'); | |
module.exports = inject( | |
['$scope', '$location', '$filter'], | |
function ($scope, $location, $filter) { | |
// some angular code | |
}); |
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
// mainCtrl.js | |
var inject = require('ng-injector'); | |
inject('$scope'); | |
inject('$location'); | |
inject('$filter'); | |
module.exports = inject(function ($scope, $location, $filter) { | |
// some angular code | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment