I want to append a template when the user presses a button. I also want to invoke the corresponding controller. Unfortunately I dont have any idea how to to that.
Can anybody help?
You can just append your template and create a new scope for. Afterwards you just need to compile it in order to invoke the controller.
So after you have appended your template:
var new_scope = $scope.$new();
$compile( $tmpl ) ( new_scope );
That also invokes your controller
Use a Routes Application:
var application = {};
var App = angular.module('application');
App.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/products', { templateUrl: 'views/products/list.html', controller: ProductsControllers })
.when('…', { templateUrl: '…', controller: ... });
}]);
After only link to "/products" for example.