Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Directives
Message
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Divers
Thread ID:
01605023
Message ID:
01605031
Vues:
26
With your help I think I got it now:
(function () {
    'use strict';

    var app = angular.module('sysMgrApp');

    app.directive('smFocus', [ '$timeout', function ($timeout, $parse) {
        return {
            restrict: 'A',

            link: function (scope, element, attribute) {
                var attribValue = attribute.smFocus;

                if (attribValue == '')
                    attribValue = true;
                else
                    attribValue = scope.$eval(attribValue);

                console.log('Element Id= ' + element[0].attributes["id"].value + ' attribValue=' + attribValue);
                if (attribValue== true) {
                    scope.$on('sm:focus', function () {
                        $timeout(function () {
                            element[0].focus();
                        }, 10);
                    });
                }
            }
        };
    }]);
})();
It is probably bad code, but seems to be working. If I have sm-focus it works and if I have it with the value of the variable, it seems to work as well (although I had to change the controller to define that variable earlier).
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform