简体   繁体   English

AngularJS:TypeError:无法读取未定义的属性“childNodes”

[英]AngularJS : TypeError: Cannot read property 'childNodes' of undefined

I have a controller inside which I have two toggle buttons to display the view accordingly.我有一个控制器,里面有两个切换按钮来相应地显示视图。 The two types of view that are shown in the controller are controlled by the $scope.isStore variable which is the deciding factor in the html part.控制器中显示的两种类型的视图由$scope.isStore变量控制,该变量是html部分的决定因素。

But once I toggle the part that is supposed to be changed becomes blank and I get the following error.但是一旦我切换应该更改的部分就变成空白,并且出现以下错误。

angular.js:13424 TypeError: Cannot read property 'childNodes' of undefined
at nodeLinkFn (angular.js:9017)
at compositeLinkFn (angular.js:8333)
at compositeLinkFn (angular.js:8336)
at compositeLinkFn (angular.js:8336)
at publicLinkFn (angular.js:8213)
at lazyCompilation (angular.js:8551)
at boundTranscludeFn (angular.js:8350)
at controllersBoundTransclude (angular.js:9072)
at ngIfWatchAction (angular.js:25323)
at Scope.$digest (angular.js:16869)

I tried looking for solutions but none worked for me.我尝试寻找解决方案,但没有一个对我有用。 Even when setting a setTimeout function when changing the $scope variable gives the same output.即使在更改 $scope 变量时设置setTimeout函数也会给出相同的输出。

HTML Part : HTML 部分:

        <div id="go-pro" class="storeCoins" ng-if="isPremiumUser==true">
            <span class="coinText">you are Premium User</span>
            <img class="imgPro"  id="feature" ng-src="/app/app_resources/icons/pirate_girl.png" />
        </div>


            <table id="links" class="tab-selector">
                <tr>
                    <td class="tablinks" ng-class="{highlighwallet: isStore==true}" ng-click="walletController.showStore(event)">STORE</td>
                    <td class="tablinks" ng-class="{highlighwallet: isStore==false}" ng-click="walletController.showHistory(event)">TASK HISTORY</td>
                </tr>
            </table>



            <div ng-if="isStore==false">
                <ul>
                    <li class="taskList" ng-click="arbit()">
                        <div class="taskHistoryList" ng-repeat="taskList in mergedTransaction | orderBy:'-Date'">
                            <img  class="taskListImage" ng-src="{{walletController.getImage(taskList)}}">
                            <span ng-show="isCoinBought">{{ taskList.coin_value}}</span>
                        </div>
                    </li>
                </ul>
            </div>


            <div ng-if="isStore==true">
                <packgroup-directive>
                </packgroup-directive>
                 <div ng-controller="WalletController">
                   <outfit-directive></outfit-directive>
                 </div>
                   <h3>GO PRO</h3>
                <div id="go-pro" ng-if="isPremiumUser==false">
                    <img class="feature" ng-click="walletController.onGoPremiumChosen()" id="feature" ng-src="/app/app_resources/language/en/resources/banner.jpg" />

                </div>

            </div>
        </div>

JS Part : JS部分:

walletModel.showStore = function () {
        console.log("ShowStore")
          $scope.isStore = true;
          $scope.$apply();
    }

Full Controller JS : https://justpaste.it/1dqxh完整的控制器 JS: https : //justpaste.it/1dqxh

JS for the directive : https://justpaste.it/1dqxj JS 指令: https : //justpaste.it/1dqxj

Do you know difference between ng-if and ng-show ?你知道ng-ifng-show之间的区别吗?

ng-if do not create element when its value is false, ng-if当元素值为 false 时不创建元素,

and ng-show active just like hidden .ng-show active 就像hidden

So to fix your problem, I think, you should have to change ng-if to ng-show or control this in '.js'因此,要解决您的问题,我认为您应该将ng-if更改为ng-show或在 '.js' 中控制它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 TypeError:无法读取未定义角度的属性“childNodes” - TypeError: Cannot read property 'childNodes' of undefined angular Javascript和XML-未捕获的TypeError:无法读取未定义的属性&#39;childNodes&#39; - Javascript and XML - Uncaught TypeError: Cannot read property 'childNodes' of undefined Uncaught TypeError:无法读取未定义的属性&#39;childNodes&#39;在Chrome和Mozilla中不起作用 - Uncaught TypeError: Cannot read property 'childNodes' of undefined not working in Chrome and Mozilla Javascript:未捕获的TypeError:无法读取未定义的属性&#39;childNodes&#39; - Javascript: Uncaught TypeError: Cannot read property 'childNodes' of undefined 未捕获的TypeError:无法读取null的属性&#39;childNodes&#39; - Uncaught TypeError: Cannot read property 'childNodes' of null AngularJs:TypeError:无法读取未定义的属性“控制器” - AngularJs: TypeError: Cannot read property 'controller' of undefined TypeError:无法读取未定义的AngularJS的属性“ unshift” - TypeError: Cannot read property 'unshift' of undefined AngularJS TypeError:无法读取Angular.js中未定义的属性“ 0” - TypeError: Cannot read property '0' of undefined in Angularjs AngularJS-TypeError:无法读取未定义的属性“ canonicalUrl” - AngularJS - TypeError: Cannot read property 'canonicalUrl' of undefined AngularJS + JQuery = TypeError:无法读取未定义的属性“ then” - AngularJS + JQuery = TypeError: Cannot read property 'then' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM