app.config(function($routeProvider) {
$routeProvider
.when('/skills', {
templateUrl: 'skill.html',
controller: 'SkillThemeCtrl'
})
.when('/exp', {
templateUrl: 'exp.html',
controller: 'ExpThemeCtrl'
})
.when('/', {
redirectTo: '/skills'
})
.otherwise({
template: '<h1>404</h1>' //or templateUrl: '<h1>404</h1>'
});
});
app.controller('ThemeCtrl', ['$http',
function($http) {
var ctrl = this;
ctrl.updateTheme = function(getTab) {
}
}
]);
app.controller('SkillThemeCtrl', function() {
updateTheme(1); //This is not working. This function is in ThemeCtrl
});
app.controller('ExpThemeCtrl', function() {
updateTheme(2); //This is not working. This function is in ThemeCtrl
});
我要訪問從另一控制器控制器裏面定義的函數。我只是在學習Angular,所以請簡單點。我嘗試了不同的方法,我正在練習其他語言,但沒有機會。非常感謝
使用工廠/服務建立自己的共同作用。 –