我试着用angularjs改进我们的巨型js(jquery)遗产。 现在我的第一个问题,从简化代码开始:
angularApp.js:
angular.module('ngSomeApp', [])
// changed interpolate provider to avoid smarty cancer
.config(['$interpolateProvider', function ($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}])
// getting party started
.controller('ngSomeController', ['$scope', '$http', function($scope, $http) {
$scope.test = 'Hello World';
console.log($scope.test);
}]); // module closed
DOM:
<html>
<head>
// loading angular.min.js (1.4.6)
// loading angularApp.js
</head>
<body>
<div ng-app="ngSomeApp">
[[2+2]]
<div ng-controller="ngSomeController">
[[2+2]]
[[test]]
</div>
</div>
</body>
我的问题是:
Object {_configBlocks:Array [0],_ runBlocks:Array [0],require:Array [0],name:“ngSomeApp”,requiresOriginal:undefined}
代码非常简单,我没有看到问题。你有什么主意吗?你在我的代码中看到任何问题吗?
答案 0 :(得分:2)
您的代码适用于1.2.23,即使是1.4.2
注意:除了创建代码段之外,我没有改变任何内容。
angular.module('ngSomeApp', [])
// changed interpolate provider to avoid smarty cancer
.config(['$interpolateProvider',
function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
}
])
// getting party started
.controller('ngSomeController', ['$scope', '$http',
function($scope, $http) {
$scope.test = 'Hello World';
console.log($scope.test);
}
]);
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script>
<div ng-app="ngSomeApp">
[[2+2]]
<div ng-controller="ngSomeController">
[[2+2]] [[test]]
</div>
</div>
&#13;