Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/455.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 角度应用程序可以';找不到ng模板tpl.html文件_Javascript_Jquery_Html_Angularjs - Fatal编程技术网

Javascript 角度应用程序可以';找不到ng模板tpl.html文件

Javascript 角度应用程序可以';找不到ng模板tpl.html文件,javascript,jquery,html,angularjs,Javascript,Jquery,Html,Angularjs,我有一个简单的角度TabCtrl,可以加载不同的模板文件。我包括模板文件本身,如下所示: <script type="text/ng-template" id="summary.tpl.html"> // Actual template elements </script> 编辑:JS文件 myApp.controller('TabsCtrl', ['$scope', function ($scope) { $scope.tabs = [{ labe

我有一个简单的角度
TabCtrl
,可以加载不同的模板文件。我包括模板文件本身,如下所示:

<script type="text/ng-template" id="summary.tpl.html">
  // Actual template elements
</script>
编辑:JS文件

myApp.controller('TabsCtrl', ['$scope', function ($scope) {
  $scope.tabs = [{
      label: 'one',
      icon: 'one',
      url: 'summary.tpl.html'
    }, {
      label: 'two',
      icon: 'two',
      url: 'downloads.tpl.html'
    }, {
      label: 'three',
      icon: 'three',
      url: 'ads.tpl.html'
    }, {
      label: 'four',
      icon: 'four',
      url: 'landing.tpl.html'
    }, {
      label: 'five',
      icon: 'five',
      url: 'retargeted.tpl.html'
  }];

  $scope.activeTab = 'summary.tpl.html';

  $scope.onClickTab = function(tab) {
    $scope.activeTab = tab.url;
  }

  $scope.isActiveTab = function(tabUrl) {
    return tabUrl == $scope.activeTab;
  }
}]);
您的
ng include=“activeTab”
定义在
ng controller=“TabsCtrl”
中的
TabsCtrl
范围之外

尝试将其添加到div
id=“wrapper”

在这种情况下,
activeTab
将在整个
ng app=“myApp”
范围内可用。

您的
ng include=“activeTab”
ng controller=“TabsCtrl”
中的
TabsCtrl
范围外定义

尝试将其添加到div
id=“wrapper”


在这种情况下,
activeTab
将在整个
ng app=“myApp”
范围内可用。

您的JSFIDLE适合我。我知道,JSFIDLE非常适合我。我在我自己的网站上复制了它,几乎是逐行复制,它没有加载模板。看起来我们需要你发布更多的代码。不确定,它应该可以工作。。。我想不出一个原因。这可能是一个愚蠢的问题-你所有的标签都关闭了吗?TabCtrl和ng应用程序设置是否正确?你的ng模板在有ng应用程序的元素中吗?你能发布定义TabsCtrl的js文件吗?你的JSFIDLE适合我。我知道,JSFIDLE工作得很好。我在我自己的网站上复制了它,几乎是逐行复制,它没有加载模板。看起来我们需要你发布更多的代码。不确定,它应该可以工作。。。我想不出一个原因。这可能是一个愚蠢的问题-你所有的标签都关闭了吗?TabCtrl和ng应用程序设置是否正确?您的ng模板是否在包含ng应用程序的元素中?您是否可以发布定义TabsCtrl?+1的js文件,以获得详细答案并不断改进您的答案,即使答案已被接受。我真的很喜欢。谢谢,我也喜欢,因为请帮助我避免这些简单的问题,因为这些问题会让我们浪费几个小时来寻找答案。…+1获得详细的答案,并不断改进您的答案,即使答案被接受。我真的很喜欢。谢谢,我也喜欢,因为帮助我防止这个简单的问题,让我们浪费几个小时去寻找它。。
myApp.controller('TabsCtrl', ['$scope', function ($scope) {
  $scope.tabs = [{
      label: 'one',
      icon: 'one',
      url: 'summary.tpl.html'
    }, {
      label: 'two',
      icon: 'two',
      url: 'downloads.tpl.html'
    }, {
      label: 'three',
      icon: 'three',
      url: 'ads.tpl.html'
    }, {
      label: 'four',
      icon: 'four',
      url: 'landing.tpl.html'
    }, {
      label: 'five',
      icon: 'five',
      url: 'retargeted.tpl.html'
  }];

  $scope.activeTab = 'summary.tpl.html';

  $scope.onClickTab = function(tab) {
    $scope.activeTab = tab.url;
  }

  $scope.isActiveTab = function(tabUrl) {
    return tabUrl == $scope.activeTab;
  }
}]);
<div id="wrapper" ng-controller="TabsCtrl">
       ...

       $rootScope.activeTab = 'summary.tpl.html';