简体   繁体   English

包含ng-include,angularjs的页面

[英]include page with ng-include, angularjs

Im trying to include a file with ng-include, but it don't work. 我试图用ng-include包括一个文件,但是不起作用。 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:

<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>

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

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