2015-12-21 69 views
-1

我想創建一個編輯配置文件表格。但我的任務是我的editprofile.js不執行。但我給editprofile.js路徑在head之間的標籤。使用AngularJS JavaScript連接節點JavaScript

但它不加載JavaScript文件,如何將節點JavaScript與AngularJS JavaScript連接起來?

<!DOCTYPE html> 
    <html ng-app="payloads"> 
    <head> 
     <meta charset="utf-8"> 
     <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
     <meta name="viewport" content="width=device-width, initial-scale=1"> 
     <title>Payload | Edit</title> 
     <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> 
     <!-- load jquery --> 
     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script> 
      <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> 
      <!-- SPELLS --> 
      <script src="/editprofile.js"></script> 
      <!-- load angular --> 
    </head> 
<div id="column-content"> 
<img alt="payload" src="/images/logo.png"> 
<myspan>Payload</myspan> 
</div> 

<body ng-controller="myCtrl"> 
    <div style="float:right; position:fixed ; right:0 ; bottom:0"> 
     <img> 
    </div> 

    <!-- You only need this form and the form-basic.css --> 
    <form class="form-basic" method="post" action="/kyc/edit"> 
     <div class="form-row"> 
      <div class="fontSize">KYC</div> 
     </div> 

     <div class="form-row"> 
      <div class="greyColor">Know Your Customer</div> 
     </div> 

     <div class="form-row"> 
      <div class="ss-required-asterisk" aria- hidden="true">* Required</div> 
     </div> 

     <div class="form-row"> 
      <label> 
       <span>LegalName*</span> 
       <input type="text" name="name" ng-model="name" required> 
      </label> 
     </div> 

     <div class="form-row"> 
      <label> 
       <span>CNIC Number*</span> 
       <input name="cnic" ng-model="cnic" required> 
      </label> 
     </div> 

     <div class="form-row"> 
      <label> 
       <span>Father Name*<br></span> 
       <input name="fatherName" ng-model="fatherName" required> 
      </label> 
     </div> 

     <div class="form-row"> 
      <label> 
       <span>Occupation*</span> 
       <input name="occupation" ng-model="occupation" required> 
      </label> 
     </div> 

     <div class="form-row"> 
      <label> 
       <span>NTN Number</span> 
       <input name="ntn" ng-model="ntn"> 
      </label> 
     </div> 

     <div class="form-row"> 
      <div class="fontSize">Contact Details</div> 
     </div> 

     <div class="form-row"> 
      <button type="submit">Save Changes</button> 
     </div> 
    </form> 
</body> 
</html> 

editprofile.js

這是JavaScript文件,顯示在輸入文本字段用戶資料數據。

var app = angular.module('payloads', []); 
var userController = require('./controllers/userController').profileDataArray; 
var profiledata = []; 
profiledata = profiledata.concat(userController()); 
app.controller('myCtrl', function($scope) { 
    $scope.name = profiledata[0]; 
    $scope.cnic = profiledata[1]; 
    $scope.fatherName = profiledata[2]; 
    $scope.occupation = profiledata[3]; 
    $scope.ntn = profiledata[4]; 
}); 
+2

你能清理一下代碼嗎?非常難以閱讀。最好把它放在一個笨蛋或jsfiddle。 – SoluableNonagon

+0

這裏相當混亂,你引用了AngularJS兩次。刪除舊的。 –

+0

我刪除了舊的一個引用的AngularJS。但仍然問題editprofile.js無法執行。 –

回答

0

隨着require呼叫editprofile.js你似乎想從您的客戶端UI代碼中加載服務器端代碼的NodeJS。這是行不通的。

您的客戶端和服務器需要能夠通過AJAX進行通信(例如,在客戶端使用Angular的$http方法,並在服務器端使用http.createServer)。