首页 > 解决方案 > 如何在html中放置角度js控制器

问题描述

在我的angular js应用程序中,我们ui-router用于路由。目前我们将所有控制器都放置在外部js文件中,并且这些js文件包含在index.html文件中,但是根据性能明智的应用程序加载速度非常慢。

如果我们在 html 文件中声明控制器,则会显示未定义控制器之类的错误。任何人都可以帮助解决这个问题。 截屏

标签: angularjs

解决方案


这是代码

<script>
    angular.module('testApp').controller('TestCtrl1', function ($scope,$http,$stateParams) {
        $scope.test = "test sample";
    });

<div class="container-fluid" style="min-height:595px;" ng-controller="TestCtrl1">
<h1>{{test}} page</h1>


推荐阅读