generator-gulp-angular icon indicating copy to clipboard operation
generator-gulp-angular copied to clipboard

write all modules together?

Open brucejcw opened this issue 8 years ago • 4 comments

I've updated to lastest version, using ES6, and all angular module are defined in index.module.js, how to define controller, directive, filter in each component ?


/* global malarkey:false, moment:false */

import { config } from './index.config';
import { routerConfig } from './index.route';
import { runBlock } from './index.run';
import { MainController } from './main/main.controller';
import { GithubContributorService } from '../app/components/githubContributor/githubContributor.service';
import { WebDevTecService } from '../app/components/webDevTec/webDevTec.service';
import { NavbarDirective } from '../app/components/navbar/navbar.directive';
import { MalarkeyDirective } from '../app/components/malarkey/malarkey.directive';

angular.module('app', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr'])
  .constant('malarkey', malarkey)
  .constant('moment', moment)
  .config(config)
  .config(routerConfig)
  .run(runBlock)
  .service('githubContributor', GithubContributorService)
  .service('webDevTec', WebDevTecService)
  .controller('MainController', MainController)
  .directive('acmeNavbar', NavbarDirective)
  .directive('acmeMalarkey', MalarkeyDirective);

brucejcw avatar Jun 02 '16 07:06 brucejcw

You have to create new angular modules in which you add your controllers and directives. You make the link by adding your new module in this module as a dependency next to the libs.

Swiip avatar Jun 02 '16 10:06 Swiip

@Swiip Could you give me some example ? thanks

brucejcw avatar Jun 02 '16 14:06 brucejcw

I dont know if is the better solution, I did this:

// app/components/login/index.module.js import {AuthService} from './authenticate.service'; import {LoginController} from './login.controller';

angular.module('loginModule', []) .service('AuthService', AuthService) .controller('LoginController', LoginController);

// .index.module.js

import { config } from './index.config'; import { routerConfig } from './index.route'; import { runBlock } from './index.run'; import { MainController } from './main/main.controller'; import { GithubContributorService } from '../app/components/githubContributor/githubContributor.service'; import { WebDevTecService } from '../app/components/webDevTec/webDevTec.service'; import { NavbarDirective } from '../app/components/navbar/navbar.directive'; import { MalarkeyDirective } from '../app/components/malarkey/malarkey.directive';

import {LoginModule} from '../app/components/login/index.module'; // load module, I just need gulp compiled...

angular.module('app', ['ngAnimate', 'ngCookies', 'ngTouch', 'ngSanitize', 'ngMessages', 'ngAria', 'ngResource', 'ui.router', 'ui.bootstrap', 'toastr', 'loginModule']) // inject login module .constant('malarkey', malarkey) .constant('moment', moment) .config(config) .config(routerConfig) .run(runBlock) .service('githubContributor', GithubContributorService) .service('webDevTec', WebDevTecService) .controller('MainController', MainController) .directive('acmeNavbar', NavbarDirective) .directive('acmeMalarkey', MalarkeyDirective);

idwd avatar Jun 23 '16 09:06 idwd

@idwd, hi, I think it's a good idea.:)

brucejcw avatar Jun 24 '16 06:06 brucejcw