Last active
August 29, 2015 14:01
-
-
Save kumatch/05153614347bac264fea to your computer and use it in GitHub Desktop.
Browserify + AngularJS module example
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 angular = require('angular'); | |
module.exports = angular.module('myapp', [ | |
require('./item').name, | |
require('./sample').name | |
]); |
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 angular = require('angular'); | |
module.exports = angular.module('myapp.item', []) | |
.factory('myapp.item.registry', [ "$http", require("./registry") ] ) | |
; |
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
module.exports = function ($http) { | |
return { | |
register: function(item) { | |
// ... | |
} | |
}; | |
}; |
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 angular = require("angular"); | |
module.exports = angular.module("myapp.sample", ["myapp.item"]) | |
.controller("SampleRegistryCtrl", [ "$scope", "myapp.item.registry", require("./registry_ctrl.js") ] ); |
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
module.exports = function ($scope, registry) { | |
$scope.name = "sample" | |
$scope.register = function (item) { | |
registry.register(item); | |
//.... | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment