I am not sure where the error is but my angularjs is not being detected.
Below is my HTML and Angularjs
<apex:page controller="ApexRemoteInvokeManagerController"
docType="html-5.0" sidebar="false">
<html>
<head>
<link href="//cdn.jsdelivr.net/webjars/bootstrap-sf1/0.1.0-
beta.6/css/bootstrap-namespaced.css" rel="stylesheet"/>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.0-
beta.11/angular.min.js"></script>
<script>
var accountApp = angular.module('accountApp',[]);
accountApp.factory('accountAndContactsFactory', ['$q',
'$rootScope', function($q, $rootScope) {
this.save = function() {
var deferred = $q.defer();
var contactJson = JSON.stringify(contact);
var accountJson = JSON.stringify(account);
Visualforce.remoting.Manager.invokeAction(
'ApexRemoteInvokeManagerController.saveAccountWithContact',
contactJson,
accountJson,
function(result, event) {
$rootScope.$apply(function() {
if (event.status) {
deferred.resolve(result);
} else {
deferred.reject(event);
}
})
},
{ buffer: true, escape: true, timeout: 30000 }
);
return deferred.promise;
}
}]);
accountApp.controller('MainController',function($scope,
'accountAndContactsFactory',function($scope,
accountAndContactsFactory))
{
$scope.save = function(contact,account){
accountAndContactsFactory.save(contact,account).then(function(result)
{$scope.message = "success";},
function(error) {$scope.message = "wrong";}
)
}
});
</script>
</head>
<body>
<div class="bootstrap" ng-app="accountApp" ng-
controller="MainController">
<form name="simpleForm" novalidate="novalidate">
<table>
<tr>
<td>First Name:</td><td><input type="text" name="FirstName" ng-
model="contact.FirstName"/></td>
</tr>
<tr>
<td>Last Name:</td><td><input type="text" required="true"
name="LastName" ng-model="contact.LastName"/>
<span class="error" ng-
show="simpleForm.LastName.$error.required">Required!</span></td>
</tr>
<tr>
<td>Business Name:</td><td><input type="text" required="true"
name="BusinessName" ng-model="account.Name"/>
<span class="error" ng-
show="simpleForm.BusinessName.$error.required">Required!</span></td>
</tr>
<tr>
{{message}}
</tr>
<tr>
<input type="button" ng-click="save(contact,account)" ng-
disabled="simpleForm.$pristine || simpleForm.$dirty &&
simpleForm.$invalid" value="Save"/>
</tr>
</table>
</form>
</div>
</body>
</html>
</apex:page>
My Apex Controller
global class ApexRemoteInvokeManagerController {
public ApexRemoteInvokeManagerController() {
}
public ApexRemoteInvokeManagerController(ApexPages.StandardController
controller)
{
}
@RemoteAction
global static void saveAccountWithContact(String contactJson,String
accountJson)
{
Account a = (Account)JSON.deserialize(accountJson,Account.class);
insert a;
Contact c = (Contact)JSON.deserialize(contactJson, Contact.class);
c.AccountId = a.Id;
upsert c;
}
}