Can't read length of undefined property aside

I am using fancy, warning and third party ng strap. They all work fine on their own, but when I try to put a warning or modally aside it gives me this error:

Uncaught TypeError: Unable to read property 'length' of undefined.

Here's the plunkr: http://plnkr.co/edit/vLbDAarzpbT3qk0aNw12?p=preview

I used the same code (copied and pasted) for the modal / alert buttons on the side and outside.

<button type="button" class="btn btn-default" data-animation="am-fade-and-scale" data-placement="center" bs-modal="myModal">Modal!</button>
<button type="button" class="btn btn-default" data-placement="top" data-container="body" data-duration="3" bs-alert="errorAlert">Alert!</button>

      

How can I solve this?

+3


source to share


1 answer


<div class="aside-body">
    <button type="button" class="btn btn-default" data-animation="am-fade-and-scale" data-placement="center" ng-click="$isShown = false" bs-modal="myModal">Modal!</button>
    <button type="button" class="btn btn-default" data-placement="top" data-container="body" data-duration="3" ng-click="$isShown = false" bs-alert="errorAlert">Alert!</button>
</div>

      



  • The ng-strap library sets the $ isShown variable in scope to indicate whether a modal file is open.
  • When you click "Click to open aside", it sets this variable to true. When you click the Modal button inside, it checks that variable, sees that it is opening (but it is actually a different modal), so it switches the modal to close. But the modal button "Modal" is not actually shown yet, causing the error
  • Not sure how to fix this correctly because I haven't used this library before. One "hack" to get the modal to work is to manually set the $ isShown variable to false when you click the "Modal" button inside, like the code above: ng-click = "$ isShown = false"
  • Plunkr: http://plnkr.co/edit/qVy1Gol7RWGnsNUCMBWm?p=preview
+1


source







All Articles