Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ng-model on <form>, binding of contained controls as members by 'name' attribute  #1716

@eddelplus

Description

@eddelplus

I think it would be really cool to make

<form name="formNewEntry" ng-model="newentry"> <input type="text" name="alias" required> <input type="email" name="email"> <input type="text" name="subject" required> <textarea rows="5" name = "body"></textarea> </form>

an equivalent shortcut for

<form name="formNewEntry" class="offset1 span9"> <input type="text" ng-model="newentry.alias" required> <input type="email" ng-model="newentry.email"> <input type="text" ng-model="newentry.subject" required> <textarea rows="5" ng-model="newentry.body"></textarea> </form>

This would help to angularize existing forms quickly and reduce the amoung of ng-specific syntax in the HTML. The object in the scope that the form as whole binds to corresponds to data that may have been sent via POST to a server before.

So to word it a bit more precisely: ng-bind on a form would establish a default binding for all controls withing that form. Each control that does not have a ng-bind of its own, will be bound to a member of the object that the form as a whole is bound to.

Does that make sense?

I'm currently working on CornerCouch, a CouchDB module for AngularJS. Progress has been excellent so far. $http is far superior to $.ajax in jQuery when it comes to JSON centric applications. This issue has struck me during the design of simple sample apps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions