新的角和有一个页面,我有应用程序和控制器定义。控制器后,我试图显示我从节点休息电话(我正确得到)返回的值。如果我把{{1 + 1}}我得到一个值... 我没有得到{{test}}或{{stock.symbol}}的值。我确实看到他们在萤火虫的范围变量.... 不知道我在做什么错误的模块的定义。任何帮助,将不胜感激!代码片段如下...AngularJS - 范围变量不显示在页面上
HTML
=====
<html lang="en" ng-app="tradingSystem">
..
..
{% block content %}
{% include "includes/carousel.html" %}
<div class="container" ng-controller="StockListCtrl">
<h3>Test: {{ test }} </h3>
<h3>Symbol: {{ stock.symbol }}</h3>
{% block content %}
{% include "includes/carousel.html" %}
<div class="container" ng-controller="StockListCtrl">
<h3>Test: {{ test }} </h3>
<h3>Symbol: {{ stock.symbol }}</h3>
App.JS
=======
'use strict';
/* App Module */
var tradingSystem = angular.module('tradingSystem', [
'ngRoute',
'tradingSystemAnimations',
'tradingSystemControllers',
'tradingSystemFilters',
'tradingSystemServices'
]);
controllers.js
=============
'use strict';
/* Controllers */
var app = angular.module('tradingSystem', []);
app.controller('LoginCtrl', ['$scope', 'User', function($scope, User) {
$scope.authenticate = function (user)
{
$scope.user = User.authenticate({emailAddress: user.emailAddress, password: user.password});
alert("Received " + $scope.user);
};
}]);
app.controller('StockListCtrl', ['$scope', '$http', function($scope, $http) {
$scope.test = 'This is a test';
$http.get('/api/stocks')
.success(function (stocks) {
if (!stocks) {
console.log("No results from api/stocks service ");
}
else
{
$scope.stocks = stocks;
console.log("Results: " + stocks);
console.log("Stocks Fetched: " + $scope.stocks.length)
$scope.stock = stocks[0];
console.log("Scope: " + $scope);
alert(stocks[0].symbol);
console.log($scope);
}
})
.error(function (reason) {
alert(reason);
});
}]);
不确定为什么要声明你的应用两次,这可能是一个问题。如果你可以在plnkr中重现它,这将有所帮助。 –