我已經表明我下面的問題的一個簡化版本:數據綁定在視圖頁面無法正常工作 - Angular.js
該指令「名」是不理解時,它是在視圖「loginView.html」,但是它正常工作時,它的主網頁是index.html,
loginView.html
<p>Welcome : {{name}}</p>
<input type="text" data-ng-model="name"><br>
<button type="submit" data-ng-click="loginUser()">Login</button>
的index.html
<!doctype html>
<html data-ng-app="vla">
<head>
<title>Video Learning application</title>
<link rel="stylesheet" type="text/css" href="css/style.css"/>
</head>
<body>
<div class = "navBar">
<div class = "leftButton"></div>
<div class = "title">VLA</div>
<div class = "rightButton"></div>
</div>
<div data-ng-view=""></div>
<script src="scripts/angular.js"></script>
<script src="scripts/angular-route.js"></script>
<script src="controllers/controllers.js"></script>
<script src="app.js"></script>
</body>
</html>
個
app.js
var app = angular.module('vla', ['ngRoute']);
app.config(function ($routeProvider){
$routeProvider
.when('/view1',
{
controller: 'controllers/controllers.js',
templateUrl: 'partials/loginView.html'
})
.otherwise({ redirectTo: '/view1' });
});
controller.js
app.controller('loginController', function ($scope)
{
$scope.loginUser = function() {
alert("test");
}
});
輸入的{{名}}只是打印出自己的觀點 'loginView' 的時候,但能正常工作和版畫,他的內容字段放入index.html時。
我很新,希望有任何幫助。 在此先感謝
這是很難理解的問題。請創建一個工作示例。例如在plnkr.co – akonsu
您是否在控制檯中看到任何JS錯誤? – PrimosK
沒有錯誤顯示 – FootsieNG