Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 71531

Wrapping code in anonymous closures - good practice?

$
0
0

@leschirmeur wrote:

Hi there!

In an Ionic project we are wrapping code from each js file in an anonymous closure like this:

(function () {
    'use strict';

    angular
            .module('demo')
            .controller('HomeController', HomeController);

    /* @ngInject */
    function HomeController(ENV) {
        var vm = this;

        // vm variables
        vm.environment = ENV.name;

        // vm functions
        vm.createGroup = createGroup;
        vm.openMyProfileModal = openMyProfileModal;

        _activate();

        /////////////////

        function _activate() {

        }

        function createGroup() {

        }

        function openMyProfileModal() {

        }
    }
})();

I'd like to ask if this is being seen by the community as good practice.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 71531

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>