मुझे लगता है कि ऐसा करने का सबसे अच्छा तरीका है ng-switch
, सिर्फ एक नियंत्रक, एक मार्ग है, कोई पुनः लोड उपयोग करने के लिए हो सकता है, चर सभी चरणों में साझा है, इस तरह का उपयोग कर:
<div ng-controller="stepCtrl">
<div ng-switch="step">
<div ng-switch-when="1">
<!-- here you can include your step 1 template,
or simply just hardcode it here: -->
<div ng-include src="'.../step1.html'">
<button ng-click="setStep(1)"></button>
</div>
<div ng-switch-when="2">
<div ng-include src="'.../step2.html'">
<button ng-click="setStep(2)"></button>
</div>
<div ng-switch-when="3">
<div ng-include src="'.../step3.html'">
<button ng-click="setStep(3)"></button>
</div>
</div>
</div>
yourApp.controller('stepCtrl',function($scope){
$scope.step = 1;
$scope.setStep = function(step){
$scope.step = step;
}
});
इस तरह आप यूआरएल को अपने वर्तमान स्थान के अंत में एक कदम जोड़ने के लिए भी कुशलतापूर्वक उपयोग कर सकते हैं।
अद्यतन:
वास्तव में इस सवाल का जवाब बहुत समय पहले के लिए है, इस दिन मैं व्यक्तिगत रूप से ui-router जो एक महान मॉड्यूल जो आप अपने AngularJS आवेदन करने के लिए इंजेक्षन और यह और भी नेस्टेड साथ शांत कर सकते हैं का उपयोग करना पसंद विचार
पहले:: नेस्टेड विचारों का भाषण, bellow कुछ एनीमेशन के साथ एक multystep फार्म के लिए अपने नए दृष्टिकोण है
Using $stateProvider declare any steps you want in separate views :
app.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('wizard', {// this will be the wrapper for our wizard
url: '/wizard',
templateUrl: 'wizard.html',
controller: 'wizardController'
})
.state('wizard.stepOne', {// this will be the wrapper for our wizard
url: '/stepOne',
templateUrl: 'stepOne.html',
controller: 'wizardController'
})
.state('wizard.stepTwo', {// this will be the wrapper for our wizard
url: '/stepTwo',
templateUrl: 'stepTwo.html',
controller: 'wizardController'
})
फिर बाद में
हमारे "wizard.html" हम कुछ इस तरह हो सकता है:
<div id="container">
<div>
<h2>Our multistep form wizard</h2>
<div id="status-buttons" class="text-center">
<a ui-sref-active="active" ui-sref=".stepOne"><span>1</span> Step One</a>
<a ui-sref-active="active" ui-sref=".stepTwo"><span>2</span> Step Two </a>
</div>
</div>
<!-- Here we specify our view that is a container for our subviews(steps) , which in our case can be a form !-->
<form id="signup-form" ng-submit="submit()">
<!-- nested state views will be inserted here -->
<div ui-view></div>
</form>
</div>
और स्पष्ट रूप से हमारे चरणों के लिए, हम html फ़ाइलें अलग किया जाना चाहिए। इस तरह, हमारे पास अभी भी एक नियंत्रक है, यूआरएल अपडेट किया जाएगा, और हम कोणीय एनीमेशन भी जोड़ सकते हैं।
पढ़ें [यह] (http://stackoverflow.com/a/20029731/511374)। –
एक व्यापक प्रश्न के बजाय कोड उदाहरण के साथ एक विशिष्ट प्रश्न पूछने में मदद कर सकता है। – lucuma
@ ल्यूकुमा मैं सहमत हूं। अगर मेरे मन में एक विशिष्ट सवाल था तो मैं इसे तैयार करूंगा। लेकिन, मैं एक दृष्टिकोण की तलाश में हूं। मैं सिर्फ यह नहीं जानता कि विभिन्न यूआरएल के बिना कोणीय में बहु-चरण/विज़ार्ड प्रकार की स्थिति कैसे संभाली जाती है। – whyceewhite