MD Ghouse MD Ghouse - 1 month ago 6
AngularJS Question

"Error: [ng:areq] Argument 'HelloHell' is not a function, got undefined

Please give me wher im doing Worng

<div ng-app="customCharts">

<div ng-controller="HelloHell">

</div>
</div>


Angular

var app = angular.module('customCharts', []);


var app = angular.module('customCharts', ['dx']);

app.controller("ChartController", function ($scope, $http, $q) {
$scope.productSettings = {
dataSource: new DevExpress.data.DataSource({
load: function () {
var def = $.Deferred();
$http({
method: 'GET',
url: 'http://localhost:53640/Home/PostChart'
}).success(function (data) {
def.resolve(data);
});
return def.promise();
}
}),
series: {
title: 'Displays Product Costs for items in our Database',
argumentType: String,
argumentField: "Name",
valueField: "Cost",
type: "bar",
color: '#008B8B'
},
commonAxisSettings: {
visible: true,
color: 'black',
width: 2
},
argumentAxis: {
title: 'Items in Product Store Database'
},
valueAxis: {
title: 'Dollor Amount'
}
}
})


Json Controller
public JsonResult PostChart()
{
var prod = new List();
using (Ctxdb db = new Ctxdb())
{
var product = db.Products.ToList();
foreach (var p in product)
{
var thing = new { Name = p.ProductName, Cost = p.Price };
prod.Add(thing);
}
}
return Json(prod, JsonRequestBehavior.AllowGet);
}

Answer

Your controller in HTML should be

<div ng-controller="ChartController">

also you should have one module

var app = angular.module('customCharts', []);