Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Directives
Message
General information
Forum:
Javascript
Category:
Other
Title:
Miscellaneous
Thread ID:
01605023
Message ID:
01605031
Views:
27
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
Previous
Reply
Map
View

Click here to load this message in the networking platform