简体   繁体   中英

Why my ng-template not showing the value of $scope and ng-repeat in angularJS?

I have a problem now regarding my ng-template.

This is my Code:

HTML:

<script id="templates/popover.html" type="text/ng-template">
    <ion-popover-view>
    <ion-content>
        <div class="list">
        <a class="item" ng-repeat="chap in Chapters">
            {{chap}}
        </a>
        </div>
    </ion-content>
    </ion-popover-view>
</script>

Controller

$scope.Chapters = [1,2,3,4];
$ionicPopover.fromTemplateUrl('templates/popover.html', function (popover) {
        $scope.popover = popover;
    });

I have like that im working with `Ionic Popover' from this site http://codepen.io/ionic/pen/GpCst

Why my ng-repeat not showing anything..

Please help me.. Thank you

The Popover function lets you pass in a scope value. I forked the Pen to do so:

http://codepen.io/cfjedimaster/pen/thaim

The basic change is here:

$scope.Chapters = [1,2,3];
$ionicPopover.fromTemplateUrl('templates/popover.html',{scope:$scope}).then(function(popover) {
    $scope.popover = popover;
});

Make sense?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM