标签:mean
MEAN开发框架的资料很少,主要的资料还是来自于learn.mean.io网站上的介绍。于是抱着一种零基础学习的心态,在了解的过程中,通过翻译加上理解将MEAN框架一点点消化并且吸收,一步一步来,慢慢地记录我学习MEAN的点点滴滴。
$ mean user <email> $ mean user <email> --addRole <role>; $ mean user <email> --removeRole <role>;2、MEAN可以列举也可以安装和卸载模块
$ mean list $ mean install <module> $ mean uninstall <module>
// Example of registering the tokens package MyPackage.register(function(app, auth, database, Tokens) { // I can make use of the tokens within my module MyPackage.someExampleFunction('some parameter'); // I can override functions MyPackage.someExampleFunction = function(param) { //my custom logic goes here }; });
// Example of adding an angular dependency of the ngDragDrop to the MyPackage.angularDependencies(['ngDragDrop']);
<pre name="code" class="javascript">//Adding jquery to the mean project MyPackage.aggregateAsset('js','jquery.min.js'); //Adding another library - global by default is false MyPackage.aggregateAsset('js','jquery.min.js', {global:true}); //Adding some css to the mean project MyPackage.aggregateAsset('css','default.css');没有放在assets文件夹中的Javascript文件会被聚合和注入到mean项目中。如果不像这么做,那么应当放置在public/assets/js文件夹中。聚合操作支持控制聚合代码所放的位置。通常需要添加一个weight和group变量来确定它是否在正确的位置。
MyPackage.aggregateAsset('js','first.js',{global:true, weight: -4, group: 'header'});
MyPackage.settings({'someSetting':'some value'}, function (err, settings) { // You will receive the settings object on success }); // Another save settings example this time with no callback // This writes over the last settings. MyPackage.settings({'anotherSettings':'some value'}); // Get settings. Retrieves latest saved settings MyPackage.settings(function (err, settings) { // You now have the settings object });当存入信息的时候,第一个参数是JSON格式信息,第二个参数是回调函数。回调函数用来判断信息是否存入,第二个参数是可选的。当读取信息的时候,只需要一个参数即可。这个参数就是回调函数。
// The Package is past automatically as first parameter module.exports = function(MyPackage, app, auth, database) { // example route app.get('/myPackage/example/anyone', function (req,res,next) { res.send('Anyone can access this'); }); };
$stateProvider .state('myPackage example page', { url: '/myPackage/example', templateUrl: 'myPackage/views/index.html' });
//We are adding a link to the main menu for all authenticated users MyPackage.menus.add({ title: "myPackage example page", link: "myPackage example page", roles: ["authenticated"], menu: "main" });
app.get('/myPackage/example/render', function (req,res,next) { MyPackage.render('index', {packageName:'myPackage'}, function (err, html) { //Rendering a view from the Package server/views res.send(html); }); });
MyPackage.register(function(system, app) { app.set('views', __dirname + '/server/views'); // ...
angular.module('mean.mycustompackage', ['mean.system']) .config(['$viewPathProvider', function($viewPathProvider) { $viewPathProvider.override('system/views/index.html', 'mycustompackage/views/myhomepage.html'); }]);
$ mean package <packageName>
$ mean uninstall myPackage
$ mean register # register to the mean network (see below) $ cd <packages/custom/pkgName> $ mean publish
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:mean
原文地址:http://blog.csdn.net/gamesdev/article/details/46790365