简体   繁体   中英

include page with ng-include, angularjs

Im trying to include a file with ng-include, but it don't work. The file should be included when you press on a button:

<button type="submit" class="btn btn-primary" ng-click="getPartial()">Jämför</button>

Here is my function in the controller:

$scope.getPartial = function() {
            $scope.showCompare = '../partials/compare.html';
            console.log($scope.showCompare);
        };

And here is my div:

<div data-ng-include data-ng-src="showCompare"></div>

Nothing is included. Have I done something wrong?

change this:

<div data-ng-include data-ng-src="showCompare"></div>

to either this:

<div data-ng-include src="showCompare"></div>

or this:

<div data-ng-include="showCompare"></div>

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