mercredi 4 novembre 2015

How to use ng-switch in angular with Laravel 5

As per my requirement, I need to enter the information like title,type in step1 after hitting next button it should take to step2 for fill the details and when we hit submit button it should return step3 when the user is signed in, if not it should show a popup for login. As per this code it works properly upto step3 when user is logged in.While enter the information without login I cannot able to show a popupwhen hitting submit button.Can anyone please check the below code and help me out here?

My angular controller:

.controller('submit', ['$scope', '$window', 'data', function($scope, $window, data){
data.getTypes().then(function(types){
    $scope.types = types;
});

$scope.step = 1;
$scope.numberPattern = /^\d+$/;

var scroll = function(){
    $window.scroll(0, 0);
};

$scope.info = {
    "title": "",
    "sendPhotographer": null,
    "type": [],
    "weeklyPrice": "",
    "monthlyPrice": ""
};

$scope.submitStepOne = function(form){
    if(form.$valid && $scope.info.type.length){
        $scope.step = 2;
        scroll();
    }
};

$scope.submitStepTwo = function(form){
    if(form.$valid){
        data.postProperty($scope.info).then(function(response){
            $scope.step = 3;
            scroll();
        });
    }
};

$scope.addFile = function(callbackData){
    if(callbackData.ok){
        $scope.info.image = callbackData.url;
    }
};
}])

My View:

<div class="section" ng-controller="submit">
<div class="col-sm-9" ng-switch="step">
            <form name="step1" ng-submit="submitStepOne(step1)" novalidate ng-switch-when="1">
                <div class="block">
                    <h2 class="block">Tell us about your space</h2>

                    <input
                        type="text"
                        ng-required="true"
                        placeholder="Give your space a title (can be changed later)"
                        name="title"
                        ng-model="info.title">
                </div>

                <div class="block">
                    <h3 class="light-font light">Do you want us to send a professional photographer to take pictures of your space? It’s totally free of charge.</h3>
                    <div class="button" ng-class="{'hollow': info.sendPhotographer !== true}" ng-click="info.sendPhotographer = true;">Yes</div>
                    <div class="button negative" ng-class="{'hollow': info.sendPhotographer !== false}" ng-click="info.sendPhotographer = false;">No</div>
                </div>
</div>
<div class="text-center">
                    <button type="submit">Next</button>
                </div>
            </form>

            <form name="step2" ng-submit="submitStepTwo(step2)" novalidate ng-switch-when="2">
                <div class="block">
                    <h2 class="light-font block">Way to go!</h2>
                    <h3 class="light-font light">You can fill in some more information about your space below, or you can wait until later. Please make sure to leave your email and/or phone number at the bottom of the page, and we’ll get back to you within a blink of the eye.</h3>
                </div>

                <div class="block">
                    <select name="location" ng-required="true" ng-options="item.id as item.name for item in types.locations" ng-model="info.location">
                        <option value="" selected="selected">Select a location</option>
                    </select>

                    <input
                        type="text"
                        placeholder="What is the address? (optional)"
                        ng-model="info.address"
                        name="address">
<div class="text-center">
                    <button type="submit">Submit space</button>
                </div>
            </form>

            <div ng-switch-default>
                <h2 class="block">Your space has been submitted.</h2>

                <div class="autosubmit-wrapper">


                </div>
            </div>

For login I have an another controller how can I give it inside the ng-switch. Can anyone help me out here please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire