
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Build angular 1.x apps with power of npm modules.
To start using an
just replace angular.{controller|directive|...}('name', fn)
with: module.exports = require('an').{controller|...}('name', fn)
Then in your main file where you bootstrap angular application:
var app = angular.module('yourModule', [/* your regular deps */]);
// flush all registered modules:
require('an').flush(app);
// controller.js
module.exports = require('an').controller('AppCtrl', function($scope) {
$scope.message = 'Hello World';
});
// app.js
require('./controller.js'); // just make sure the controller is registered
var app = angular.module('myApp', []);
// flush controller into app:
require('an').flush(app);
// this is equivalent to:
// app.controller('AppCtrl', function() {...});
<!DOCTYPE html>
<html ng-app='myApp'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script>
</head>
<body ng-controller='AppCtrl'>
<h1>{{message}}</h1>
<script src='bundle.js'></script>
</body>
</html>
See demo folder for the same code.
Browserified output of the demo folder (browserify ./demo/app.js > ./demo/bundle.js
)
can be found here: https://anvaka.github.io/an/demo
The idea is simple: avoid using angular.module
in npm package, and delay
directives registration up to the point when application is bootstrapped.
E.g. instead of doing:
var myModule = angular.module(???, []);
myModule.directive(???, function myDirective() {/* */});
Do:
require('an').directive(function myDirective() {});
When you ready to bootstrap application, collect all directives and register them in your main application module:
require('an').flush();
This approach is still not perfect and requires certain discipline to not forget
register your directives via an
. I can also see potential problems with names
collision, versioning (especially when an
itself is updated).
This module is really simple
at the moment, and maybe there is a better way of sharing angular directives on
npm.
Please let me know.
With npm do:
npm install an
MIT
FAQs
Angular + NPM: Publish your AngularJS modules to npm
The npm package an receives a total of 11 weekly downloads. As such, an popularity was classified as not popular.
We found that an demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.