I
I
Ilya2017-01-12 01:18:39
Angular
Ilya, 2017-01-12 01:18:39

AngularJS adding ng-controller and new controller after certain time after page load?

Hello. I want to bind a new controller to a module, so that there is an ng-controller attribute , but some time after the page loads, for example, 5 seconds have passed and I need to add the ng-controller attribute to the element so that it is attached before the newly created controller, which is attached to module. Well, so that inside the element with the ng-controller attribute I could access the $scope of the controller. I am a beginner, maybe I misunderstood something and this approach is not correct. It seems that I saw a solution to this problem here at the bottom , but it did not work out. Thanks, I'd appreciate any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
ozknemoy, 2017-01-13
@kicker1337

it's better to use components. depending on the type of svg, throw parameters through bindings inside the component. For example

html:
<foto-editor
   foto-emit-callback="ctrl.setFotoUrl(id,url)"
   modal-parent-id="{{$ctrl.idCroppedImg}}"
   area-type='circle'
   foto-w='{{$ctrl.widthFromParentCtrl}}'
   foto-h='{{$ctrl.heightFromParentCtrl}}'
>
</foto-editor>

js
var fotoeditorComponent = {
    bindings: {
        fotoEmitCallback: '&',
        modalParentId: '@',
        fotoW: '@',
        fotoH: '@',
        areaType: '@?'
    },...
};

Well, it's better not to accustom yourself to $scope right away. this is laggy code

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question