Model Definition AngularJS

by cmyworld

HTML

<div ng-app='myapp'>
    <div ng-controller='TestController'></div>
</div>

JavaScript

var module = angular.module('myapp', []);
module.controller('TestController', ['SystemModel', function (SystemModel) {
    var datafield = new SystemModel.DataField();
    console.log(datafield);
}]);
//All model definition for App related model go here
module.factory('AppModel', [function () {}]);
//All model definition for Hub related model go here
module.factory('HubModel', [function () {}]);
//All model definition for System related model go here
module.factory('SystemModel', [function () {

    function System() {
        this.id = null;
        this.actionIdentifier = null;
        this.dataFieldsList = [];
    }

    function DataField() {
        this.name = null;
        this.id = null;
        this.fieldType = null;
    }

    function Action() {
        this.identifier = null;
        this.entityName = null;
        this.title = null;
    }

    function Connection() {
        this.system = new System();
        this.action = new Action();
    }

    return {
        'System': System,
            'DataField': DataField,
            'Action': Action,
            'Connection': Connection
    };
}]);