Outils pour utilisateurs

Outils du site


web:javascript:angularjs:snippets

Service

(function () {
 
    'use strict';
 
    angular.module('Module').service('Service', Service);
 
    Service.$inject = ['dependency1'];
 
    function Service(dependency1) {
 
        var that = this;
 
        // Public members
 
        // Private members
 
        // Public functions
 
        this.exposedFn = exposedFn;
 
        // Private functions
 
        function exposedFn() { }
 
    }
 
})();

Directive

angular.module("app")
    .directive("directiveName", function () {
        return {
            restrict: "E",

            scope: {
                liste: '=',
                attrib1: '&',
                attrib2: '=' 
            },

            link: function(scope, element, attrs) {

                scope.selectActivite = function(row) {
                    scope.activiteSelectionnee = row;
                };

                scope.isActivitySelected = function(rowid) {
                    return rowid === scope.activiteSelectionnee.id;
                };

            },
            templateUrl: "/client/src/app/rapport/activite/directives/listeActivites/listeActivites.html"

        };
    });

AngularJS avec TypeScript

Component

class EnjoyableComponent implements angular.IComponentOptions {
    bindings: Bindings;
    controller: any;
    controllerAs: string;
    templateUrl: string;

    constructor() {
        this.bindings = {};
        this.controller = EnjoyableController;
        this.controllerAs = 'vm';
        this.templateUrl = '~/App/views/EnjoyableComponent.html';
    }
}

angular
    .module('app')
    .component('enjoyable', new EnjoyableComponent());

web/javascript/angularjs/snippets.txt · Dernière modification : 2022/12/09 20:43 de sgariepy