简单的问题:如何在 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/