我正在使用Sails,我不会让我的角度控制器执行。这是我的layout.ejs。
<!DOCTYPE html>
<html>
<head>
<title><%=typeof title == 'undefined' ? 'New Sails App' : title%></title>
<!-- Viewport mobile tag for sensible mobile support -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<!--STYLES-->
<link rel="stylesheet" href="/styles/bootstrap.min.css">
<link rel="stylesheet" href="/styles/importer.css">
<link rel="stylesheet" href="/styles/style.css">
<!--STYLES END-->
<script type="text/javascript">
window.SAILS_LOCALS = {
me: <%- JSON.stringify(me||null) %>
};
</script>
</head>
<body ng-app="containers">
<%- partial('./partials/navigation.ejs') %>
<%- body %>
<!--TEMPLATES-->
<!--TEMPLATES END-->
<!--SCRIPTS-->
<script src="/js/dependencies/sails.io.js"></script>
<script src="/js/dependencies/angular-route.min.js"></script>
<script src="/js/dependencies/angular.js"></script>
<script src="/js/dependencies/bootstrap.min.js"></script>
<script src="/js/dependencies/jquery.min.js"></script>
<script src="/js/controllers/adminPageController.js"></script>
<script src="/js/controllers/navPageController.js"></script>
<script src="/js/controllers/ordersPageController.js"></script>
<script src="/js/controllers/welcomePageController.js"></script>
<!--SCRIPTS END-->
</body>
</html>
我执行的控制器都没有被执行,我将粘贴最简单的代码示例。这是我在运行风帆升降时进入<%- body%>
的第一个html:
<div ng-controller="welcomePageController">
</div>
这是上面调用的控制器:
angular.module('containers').controller('welcomePageController', [ '$scope', '$http', function( $scope, $http ) {
console.log("hola");
// set-up loading state
$scope.loginForm = {
loading: false
};
$scope.me = window.SAILS_LOCALS.me;
}]);
事情是,我甚至不能在我的控制台中获取日志。另外,如果我尝试在html中添加<label>{{loginForm.loading}}</label>
之类的内容,我只能打印出来{{loginForm.loading}}。