Angularjs在ng-view中不加载脚本。

23 浏览
0 Comments

Angularjs在ng-view中不加载脚本。

我有一些特定于视图的脚本。然而,当angularjs加载视图时,脚本似乎无法执行。

Index.html


  
    
    
    


Main.html - 在ng-view下加载

hello world
  

在这个例子中,当页面加载时,我在网站上看到一个基本的hello world。然而,我没有看到任何弹出窗口显示"Hello, John"。

有任何想法为什么我无法加载特定于某个视图的脚本吗?


额外信息

app.js

'use strict';
angular.module('adminApp', [])
  .config(function ($routeProvider) {
    $routeProvider
      .when('/', {
        templateUrl: 'views/main.html',
        controller: 'MainCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
  });

controllers/main.js

'use strict';
angular.module('adminApp')
  .controller('MainCtrl', function ($scope) {
    $scope.awesomeThings = [
      'HTML5 Boilerplate',
      'AngularJS',
      'Karma'
    ];
  });

0