Last active
November 9, 2015 16:19
-
-
Save alber70g/a3143e19840ebf2cd614 to your computer and use it in GitHub Desktop.
AngularJS: Using partial html for Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module app { | |
'use strict'; | |
angular | |
.module('app.entity') | |
.config(routes); | |
routes.$inject = ['$stateProvider']; | |
function routes($stateProvider: ng.ui.IStateProvider) { | |
$stateProvider | |
.state('entity', { | |
url: '/entity', | |
controller: 'app.entity.entityController', | |
controllerAs: 'entity', | |
templateUrl: 'components/entity/entity.html', | |
abstract: true | |
}) | |
.state('entity.list', { | |
url: '/list', | |
controller: 'app.entity.entityListController', | |
controllerAs: 'entityList', | |
templateUrl: 'components/entity/entityList.html' | |
}) | |
.state('entity.edit', { | |
url: '/edit/:transactionNr', | |
controller: 'app.entity.entityEditController', | |
controllerAs: 'entityForm', // EntityForm | |
templateUrl: 'components/entity/entityEdit.html' | |
}) | |
.state('entity.new', { | |
url: '/new/:transactionNr', | |
controller: 'app.entity.entityNewController', | |
controllerAs: 'entityForm', // EntityForm | |
templateUrl: 'components/entity/entityNew.html' | |
}) | |
/*inject:routes*/ | |
; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="entityCreateForm"> | |
<div ng-include="partials/entityForm.html"> | |
// this is now bound to the entityCreateController using controllerAs:entityForm | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form name="entityEditForm"> | |
<div ng-include="partials/entityForm.html"> | |
// this is now bound to the entityEditController using controllerAs:entityForm | |
</div> | |
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input name="field1" ng-model="entityForm.entity.field1"> | |
<input name="field2" ng-model="entityForm.entity.field2"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment