disable form elements in angularjs

时间:2018-07-17 10:58:14

标签: javascript angularjs

I have a component as following :

component('page', {
    transclude: true,
    templateUrl: 'page-component.html',
    controller: 'PageController',
    controllerAs: 'pc'
});

And this is how I'm using it :

<page>
    <page-section section-id="1">
        <div>
            <ng-include src="'panelX.html'"></ng-include>
        </div>
    </page-section>
    <page-section section-id="2">
        <div>
            <ng-include src="'panelY.html'"></ng-include>
        </div>
    </page-section>
</page>

In this component controller I want to disable all form elements (inputs, buttons, textareas...), so I did as following :

$("form").find('input, textarea, button, select, button').attr('disabled','disabled');

The problem I have is that this code is executed before panelX.html and panelY.html are loaded.

How can I solve this ?

Edit:

Since the application is big and it contains hundreds of forms I don't want to touch the html code, I only want the code inside the page directive to work for all forms in the application.

0 个答案:

没有答案