Created
August 30, 2011 14:33
-
-
Save mandrasch/1181031 to your computer and use it in GitHub Desktop.
Widgets: scope problem
This file contains hidden or 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
function OrganizationManagementCreateCtrl($route,$location) | |
{ | |
var self = this; | |
this.$route = $route; | |
this.test123 = 'XXX'; | |
this.formtemplate = 'partial_form.html'; | |
this.submit = function(){ | |
alert(this.form.name); | |
} | |
} | |
OrganizationManagementCreateCtrl.$inject = ['$route','$location']; |
This file contains hidden or 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
<!-- does not work: --> | |
<my:input name="name" label="Name" ns="form"></my:input> | |
<!-- does work: --> | |
<!-- <input type="text" name="form.name" /> --> | |
<!-- is inserted: --> | |
{{test123}} | |
<button ng:click="submit()">Erstellen</button> | |
<button ng:click="cancel()">Abbrechen</button> |
This file contains hidden or 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
<div ng:controller="OrganizationManagementCreateCtrl"> | |
{{test123}} | |
<ng:include src="formtemplate"></ng:include> | |
<p><a href="#/organizationManagement/">» Zurück</a></p> | |
</div> |
This file contains hidden or 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
angular.widget('my:input', function(element) { | |
this.descend(true);//2DO: does child processing? | |
var name = element.attr('name'); | |
var label = element.attr('label') || name; | |
var ns = element.attr('ns') || 'form'; //the namespace to use | |
element.append('<div class="form_field">'+ | |
'<label for="'+ns+'.'+name+'">'+label+':</label>'+ | |
'<input type="text" name="'+ns+'.'+name+'" />'+ | |
'<span class="form_error" ng:show="'+ns+'.errors.'+name+'">{{'+ns+'.errors.'+name+'}}</span>'+ | |
'</div>' | |
); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment