angularjs - 如何在html中放置角度js控制器
问题描述
在我的angular js
应用程序中,我们ui-router
用于路由。目前我们将所有控制器都放置在外部js
文件中,并且这些js
文件包含在index.html
文件中,但是根据性能明智的应用程序加载速度非常慢。
如果我们在 html 文件中声明控制器,则会显示未定义控制器之类的错误。任何人都可以帮助解决这个问题。
解决方案
这是代码
<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>
推荐阅读
- c# - 以定义的顺序调用多个方法
- laravel - 使用 Laravel Eloquent 检索所有父值
- react-native - React Navigation:切换到不同的堆栈并能够返回到上一个堆栈
- c - gsl_vector_get() 在 printf() 中返回错误值
- java - 错误:链接有关字符串资源的文件资源失败
- node.js - 限制没有学术地址 (.co.uk) 的用户。
- firebase - 为什么 Firebase Realtime db 在隐身等模式下工作,而不是 Firebase 云消息传递
- jenkins - 使用 Jenkins Multibranch 管道进行多个 GitHub 检查
- reactjs - 父母的状态没有正确地传递给孩子
- javascript - 如何使用 Chrome 扩展程序以编程方式单击 Google Docs 中的按钮?