0

ビューの読み込み時に変数を初期化しようとするTypeErrorと、ngRepeat に関連しているように見える が表示されます。

TypeError: Cannot read property 'insertBefore' of null

同じコントローラーを共有するビューがたくさんあり、変数が最初に設定される親コントローラーがあります。controllerAsスコープの問題を回避するために使用しています。親コントローラーには がthis.submitted = false;あり、子コントローラーには がありthis.submitted = true;ます。ビューHTMLでngInitを使用して、親の変数を子の変数で上書きしたい...

HTML:

<form>
    <label ng-repeat="sample in child.content" 
        ng-init="parent.inputs=child.inputs; 
            parent.submitted=child.submitted;">
        <input id="{{sample.name}}" 
            name="{{sample.name}}" 
            type="{{sample.type}}"
            value="{{sample.value}}"
            ng-model="parent.inputs[sample.name]">
        {{sample.label}}
    </label>
</form>

この部分はうまくいくようです:

parent.inputs=child.inputs

しかし、これは TypeError を引き起こします:

parent.submitted=child.submitted

4

0 に答える 0