【问题标题】:Failed to instantiate module start due to: Error: [$injector:nomod]由于以下原因无法实例化模块启动:错误:[$injector:nomod]
【发布时间】:2016-05-02 15:48:24
【问题描述】:

app.js:-

var app = angular.module('start', ['ionic']);
app.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
 cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}
});
});
app.controller('sign_up', function($scope, $http){
$scope.check_cred = function(){
document.getElementById('message').textContent="";
var request = $http({
  method:"post",
  url: "http://10.0.128.152/ionic/login.php",
  data:{
    email = $scope.email,
    pass = $scope.pass
  },
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
request.success(function(data){
  document.getElementById("message").textContent = "Login successful with "+data;
});
}
});

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title></title>

<link href="lib/ionic/css/ionic.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">

<!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
<link href="css/ionic.app.css" rel="stylesheet">
-->

<!-- ionic/angularjs js -->
<script src="lib/ionic/js/ionic.bundle.js"></script>

<!-- cordova script (this will be a 404 during development) -->
<script src="cordova.js"></script>

<!-- your app's js -->
<script src="js/app.js"></script>
</head>
<body ng-app="start"  ng-controller="sign_up">

<ion-pane>
  <ion-header-bar class="bar-header bar-dark">
    <h1 class="title">Lazywyre</h1>
  </ion-header-bar>
  <ion-content class="padding">
    <div class="list">
      <label class="item item-input">
        <input type="text" ng-model="email" placeholder="Email">
      </label>
      <label class="item item-input">
        <input type="password" ng-model="pass" placeholder="Password">
      </label>
      <button ng-click="check_cred()" class="button button-full button-positive">
        Submit
      </button>
    </div>
    <span id="message"></span>
  </ion-content>
 </ion-pane>
 </body>
</html>

我知道这是常见错误,但我已经检查了代码并且对我来说看起来不错。我无法找到错误。我到处搜索,发现语法是正确的。我是 Angular 新手,所以如果有任何愚蠢的错误请忽略并帮助我。

【问题讨论】:

  • 数据对象的语法错误应该在控制台中可见。

标签: angularjs html ionic-framework


【解决方案1】:

由于这一行,您会收到此错误:

data:{
  email = $scope.email,
  pass = $scope.pass
},

应该是:

data:{
  email: $scope.email,
  pass: $scope.pass
},

【讨论】:

    猜你喜欢
    • 2019-08-17
    • 2016-11-07
    • 2018-09-29
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 2016-05-23
    • 2022-08-22
    • 1970-01-01
    相关资源
    最近更新 更多