javascript - angular form and routing -
i have simple form search field users type in parameter , redirects them proper page.
i trying pass in argument in form in similar manner (in jade):
form(name='searchform', ng-href='#/item/{{ctrl.search}}') input(type='text', ng-model='ctrl.search') basically, want route alter #/item/argument when users press come in after having typed in search field.
how can accomplish this?
many thanks
at guess think set action attribute on form - how html forms traditionally send info url.
however typically add together handler ng-submit directive on form element instead. in handler have (remember add together $location service controller):
html
form(ng-submit="ctrl.onsubmit($event)") js (controller)
this.onsubmit = function (e) { e.preventdefault(); $location.url('item/' + this.search); } as aside, should using $scope service inject info view controller - that's it's there for.
javascript angularjs
No comments:
Post a Comment