AngulaJs CoffeeScript Grunt

268
May 03, 2017, at 3:35 PM

i'm facing to one problem for code optimization ie mangle. I use angular and require and everything worked fine except in service/factory case. There some examples (helloService.coffee)

define 'HelloService', [], ->
   'use strict'
   HS = ($timeout) ->
      sayHello: (name) ->
        $timeout ->
          console.log 'Hello: ' + name
        ,2000
   HS.$inject = ['$timeout']
   HS

And in controller i make something like this:(mainController.coffee)

define 'MainController', ['HelloService'], (HS) ->
  'use strict'
  MC = ($scope) ->
    HS.sayHello 'Stack Overflow' # it return sayHello is not a function
    # do something with scope here
  MC.$inject = ['$scope']
  MC

And there is how app.coffee look like:

define 'app', ['angular', 'HelloService', 'MainController'],(angular, HelloService, Maincontroller)->
  app = angular.module 'app', []
  app.service 'helloService', HelloService
  app.controller 'mainController', MainController
  app.bootstrap = ->
    angular.element(document).ready ->
      angular.bootstrap document, ['app']
  app

And somewhere (main.coffee)

requirejs.config
  baseUrl: ''
  paths:
    angular:['cdn_url','angular_fallback_in_project_dir']
  shim:
    angular:
       exports: 'angular'
       deps: []
require ['app'], (app) ->
  app.bootstrap()

This keep code easier to maintain plus it's really mimification friendly. If i try something like:

hs = new HS()

Then i can call hs.saylHello 'String' but now $timeout is undefined or sometime is not function. Thank in advance for your help.

READ ALSO
How can I figure out system load with express.js/node.js?

How can I figure out system load with express.js/node.js?

I am creating a basic system monitoring utility as a practice exercise, and I am wondering if there a library I can use with expressjs through which I can find out how many processes are currently utilizing the CPU?

252
nodejs - how to ensure my application is reliable all the time

nodejs - how to ensure my application is reliable all the time

I have been using forverjs for my server but for some reason the server stopped and the server didn't restart againIs foreverjs reliable?

268
IDEA nodejs mocha tests are recognized, but run as code

IDEA nodejs mocha tests are recognized, but run as code

In IntelliJ IDEA Ultimate 20171, I have a large nodejs project with many NPM modules

270