dougal
0.1.2 • Public • Published Dougal
The M of MVC, for Javascript VC frameworks that lack a decent M.
Getting Started
Install Dougal:
$ npm install aol/dougal
<script src="node_modules/dougal/dougal.js"></script>
Define models:
var Employee = Dougal.Model.extends(function () {
this.baseUrl = '/employees';
this.attribute('id');
this.attribute('name');
this.validates('name', {presence: true, message: 'Name is required'});
});
Create a new record:
var newHire = new Employee({name: 'John Doe'});
Validate the record:
newHire.isValid();
newHire.name = '';
newHire.isValid();
newHire.errors.name;
Save the record:
Angular.js integration
<script src="node_modules/dougal/dougal-angular.js"></script>
angular.module('your.app', ['dougal'])
.factory('Employee', ['Dougal', function (Dougal) {
function Employee() {
}
return Dougal.Model.extends(Employee);
}])
.controller('YourController', function (Employee) {
this.employee = new Employee();
});
Readme
Keywords
nonePackage Sidebar
Install
Weekly Downloads