2016-07-08 7 views
0

関数がボタンにonclick()で接続されている問題が発生しています。私は、UIタグ付きのHTMLページにコントローラを接続するためにUIルーティングを使用しました。ここでは、コードスニペットがある -Angled/Nodejsの未返還関数のエラー

app.js

var havyakkaMaduve = angular.module('havyakka_maduve',  ['ionic','ngStorage','ngCordova','ngCordovaOauth']) 

havyakkaMaduve.config(function($stateProvider, $urlRouterProvider) { 

    $stateProvider 

    // setup an abstract state for the tabs directive 
    .state('home', { 
    url: '/', 
    templateUrl: 'homePage.html', 
    controller: 'LoginController' 
    }) 
    .state('registration', { 
    url:'/reg', 
    templateUrl:'templates/registration.html', 
    controller:'UserDetailsController' 
    }); 

    // if none of the above states are matched, use this as the fallback 
    $urlRouterProvider.otherwise("/reg"); 

    }); 

havyakkaMaduve.controller("UserDetailsController",["$scope","$http", function($scope,$http) { 
    console.log("Inside userDetails Controller"); 
    $scope.submitDetails = function() { 
    console.log("Submitting details"); 
    $http.get("/test").success(function(response){ 
     console.log("Test success"); 
    }); 
    }; 


}]); 

Registration.html

<ion-pane> 
    <ion-content class="padding"> 
    <div class="reg_list"> 
     <label class="item item-input"> 
     <span class="input-label">Full Name</span> 
     <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Mane</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Gotra</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Date</span> 
    <input type="date" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Education</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Occupation</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Father's Name</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Mother's Name</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Current Location</span> 
    <input type="text" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Upload Image</span> 
    <input type="file" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">Digital Identity</span> 
    <input type="url" required> 
    </label> 
    <label class="item item-input"> 
    <span class="input-label">About Me</span> 
    <input type="text"> 
    </label> 
</div> 
<button class="button button-block button-positive" onclick="submitDetails">Submit</button> 
<div> 
</div> 

私が間違っているとしてつもりどこ誰かが私に教えてください私はここで何の問題も見ませんが、私は "ReferenceError:submitDetails is no t定義された "。私は "Submit"ボタンをクリックしたときに問題が見えます。ありがとうございます。

答えて

3

あなたはngのクリックの代わりにonclickのを使用する必要があり、関数が括弧で呼び出される必要があります。

<button class="button button-block button-positive" ng-click="submitDetails()">Submit</button> 
+0

感謝。しかし、今度は、submitDetails関数内の次のconsole.log()出力にログインしていないので、get要求さえも完了していません。 –

+1

申し訳ありませんが、私はその2番目の部分をキャッチしませんでした。私の答えを更新しました! – Cameron637

+0

ええ...今それは動作します。どうもありがとう。 –

関連する問題