Reputation: 1023
Hello I have tried many ways to initialize a basic app but I do not know what it is wrong. The logic is the following
I "append" the following html containing the angular js module using a jquery ajax call.
('submit', function () {
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: form.serialize(),
success: function (data) {
result.html(data);
Then the following html is loaded together with angularjs and the script having the module and controller definitions
HTML:
Load angular.js and the script where angular app is defined I type data-ng-app="app" in Body, HTML or wherever then data-ng-controller="controller" in a div or wherever i want to work on with the scope. Which should be already enough to initialize the controller. Am I right?
SCRIPT:
var app = angular.module('app', []);
app.controller('controller', ["$scope", "$http", function ($scope,$http) {
console.log('works');
...more stuffs
]);
I have tried to copy paste from the most basics examples in tutorials but still not working. No problems with dependencies or syntax errors. What can be the problem?
Thanks in advance
Upvotes: 0
Views: 322
Reputation: 222532
The issue i see with your code is you are not passing the dependencies to your function
app.controller("listController", ["$scope", "$http"
function($scope,$http) {
console.log('works');
}]);
Upvotes: 1