如何使主布局中的脚本在加载时应用于 angularjs 视图

How do I make scripts in the main layout apply to an angularjs view when it loads?

本文关键字:加载 应用于 angularjs 视图 脚本 何使主 布局      更新时间:2023-09-26

我正在尝试将angularjs集成到现有站点中。问题是我已经将主页的一部分转换为角度视图,但是当后者使用ng-route加载到主页中时,位于主页底部的主页滑块脚本似乎没有在加载的视图中呈现。

有没有人知道如何度过难关。谢谢。

</div>
</header>
<div data-ng-view></div>
<footer id="footer">
<div class="container">
(function() {
  var app = angular.module('hbcm', ['ngRoute']);
  angular.module('hbcm').controller('DsplController', function() {
    this.panel = 1;
  });
  app.config(function($routeProvider) {
    $routeProvider
      .when('/', {
        controller: 'DsplController',
        templateUrl: 'view1.html'
      })
      .when('/about-us/', {   
        templateUrl: 'about-us.html'
      })
      .otherwise({
        redirectTo: '/'
      });
  });
})();

创建一个控制器来处理您的模板(视图),并将该控制器附加到路由配置中

$routeProvider.when('/somewhere',  { controller: TheNameOfYourController, });