我有一个模块中定义的控制器:
I have a controller defined inside a module:
angular.module('myModule').controller('MyCtrl', function ($scope) {
$scope.property = 'myproperty'; });
一个部分被包含在这样的主HTML:
A partial is included in the main html like this:
<div ng-include src="'partial/mypartial.html'"></div>
是否有可能引用MyCtrl里面mypartial.html?例如某种程度上是这样的:
Is it possible to reference MyCtrl inside mypartial.html? e.g. somehow like this:
<div ng-controller="myModule.MyCtrl">
谢谢!
由于角的javascript:
Given the angular javascript:
angular.module('myModule').controller('MyCtrl', function ($scope) {
$scope.property = 'myproperty'; });
您视图设置应该是这个样子:
Your view setup should look something like:
<html ng-app>
<head>
</head>
<body>
<div ng-controller="MyCtrl">
{{property}}
</div>
</body>
</html>
以上code应该产生:
The above code should generate:
myproperty