Answer the question
In order to leave comments, you need to log in
How to make a directive?
Good afternoon. I'll try to formulate a question.
There is a Multi-Step Form (I think many have seen it). I would like to translate it into a directive, and also, most likely, each individual field into a directive. And what to do with $stateProvider in this case? You can't put it in a directive - it remains in the module config. Those. stays like this
.state('form', {
url: '/form',
template: '<form></form>',
})
.state('form.profile', {
url: '/profile',
template: '<form-profile></form-profile>'
})
.state('form.interests', {
url: '/interests',
template: '<form-interests></form-interests>'
})
.state('form.payment', {
url: '/payment',
template: '<form-payment></form-payment>'
});
angular
.module('app.core')
.directive('form', form);
function form() {
var directive = {
link: link,
template: ' <form id="signup-form" ng-submit="processForm()">
<div id="form-views" ui-view></div>
</form>',
restrict: 'EA'
};
return directive;
function link(scope, element, attrs) {
scope.formData = {}
}
}
and make field directivesangular
.module('app.core')
.directive('formProfile', formProfile);
function formProfile() {
var directive = {
link: link,
require: '^form'
templateUrl: 'views/form-profile.html">
restrict: 'EA'
};
return directive;
function link(scope, element, attrs) {
}
}
Well, the rest of the fields. Do I understand correctly that if I do in each directive require: '^предыдущая директива'
, then the controller is inherited and I will "collect" the form as a result? Answer the question
In order to leave comments, you need to log in
then the controller is inherited and I will "collect" the form as a result?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question