Marinescu Vlad Marinescu Vlad - 2 years ago 81
HTML Question

AngularJS getting error on Post method

I made an RESTful api in .net .The html is created with angularJS.

The problem is, when the page loads, i'm getting the following error:
enter image description here

and the "insert" button doesn't work anymore.

This is my insert script and the full html can be found at the link:

$scope.insert = function insert() {
var data = {"id": 3, "name": $, "description":$scope.description , "price": $scope.price, "categoryid": $scope.categoryid};
headers: {
'Content-Type': 'application/json'
).success(function (data) {

If you are kind to help me to make Edit button works as the following model: to make HTTPPut to api, it will be wonderful.

All Restful requests works, api works, tested with PostMan

I'm kinnda newbie to AngularJS so your help will be very useful for me. Thanks a lot !

Answer Source

Your insert function is part of 'ProductController', not 'FormCtrl'.

So in your html, do this:

<div ng-controller="ProductController">

and you will get rid of that error.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download