0
試圖瞭解它可以在不同模塊下的控制器之間進行通信。這甚至有可能嗎?從不同模塊和控制器獲取角度變量
這裏是我的測試,我想學習從:
HTML
<div ng-app="app">
<div ng-controller="AppCtrl">
<p data-ng-bind="group.name"></p>
<p data-ng-bind="project.name"></p>
</div>
<div ng-controller="ProjectCtrl">
<p data-ng-bind="group.name"></p>
<p data-ng-bind="project.name"></p>
</div>
<div ng-controller="GroupCtrl">
<p data-ng-bind="group.name"></p>
<p data-ng-bind="project.name"></p>
</div>
</div>
的JavaScript
var app = angular.module('app', ['project', 'group']);
var group = angular.module('group', ['project']);
var project = angular.module('project', ['group']);
app.controller('AppCtrl', ['$scope', 'Project', 'Group', function($scope, $project, $group) {
$scope.project = Project;
$scope.group = Group;
$scope.name = 'My App';
}]);
project.controller('ProjectCtrl', ['$scope', 'Project', 'Group', function($scope, $project, $group) {
$scope.project = Project;
$scope.group = Group;
$scope.name = 'My Project';
}]);
group.controller('GroupCtrl', ['$scope', 'Project', 'Group', function($scope, $project, $group) {
$scope.project = Project;
$scope.group = Group;
$scope.name = 'My Group';
}]);
謝謝,這正是我需要學習的東西 – abritez 2014-08-28 17:00:30