一个简单的问题:如何在html中设置作用域值,以供控制器读取?
var app = angular.module('app', []);
app.controller('MyController', function($scope) {
console.log($scope.myVar);
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app='app'>
<div ng-controller="MyController" app-myVar="test">
{{myVar}}
</div>
</div>
JSFiddle:http : //jsfiddle.net/ncapito/YdQcX/