次のようなモジュール パターンを使用してコントローラーを定義したいと思います。
(function(ng, app) {
// Controller constructor.
function Controller($scope) {
this.scope = $scope;
this.scope.fmembers = [
{
name: 'Member 1',
role: 'Head of Family',
age: 55
},
{
name: 'Member 2',
role: 'Brother of Head of Family',
age: 51
}
];
Controller.prototype = {
getFMembers: function() {
return this.scope;
}
};
return( this );
}
// Define the Controller as the constructor function.
app.controller('ftreeController', Controller );
})(angular, anmDesktop);
その場合、モジュールからこのコントローラー (ftreeController) を取得するにはどうすればよいですか? たとえば、app.config の routeprovider で freeController を使用したいと思います。
$routeProvider.when('/view2', {
templateUrl: 'partials/partial2.html',
controller: ftreeController'
});
上記の routeprovider で、エラーが発生します (ftreeController が定義されていません...)
ありがとうございました。