AngularJS脚本不起作用

时间:2015-03-08 03:24:30

标签: angularjs ionic

我无法制作一个简单的AngularJS来处理我的离子应用。它说这个功能未定义。

首先,这些是我项目的基本文件

的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">
    <link href="css/glsmile.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>
    <script src="js/main.js"></script>
  </head>
  <body ng-app="">
    <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">GL Smile Filter</h1>
      </ion-header-bar>
      <ion-content>
          <div id="wrapper">
              {{1+1}}
              <div ng-controller="StoreController">
              </div>

              <select>
                  <option selected>Choose your region</option>
                  <option>Mississsauga</option>
                  <option>North York</option>
              </select>
                <br>
              <select>
                  <option selected>School near by</option>
                  <option>University Of Toronto</option>
                  <option>Waterloo</option>
                  <option>Sheridan College</option>
              </select>

                <input type="range" name="rangePrice" min="0" max="600" id="rangePrice"
                       oninput="showVal(this.value)" onchange="showVal(this.value)">
                    <p div style="display:inline; float:left;">$0</p> <p div style="display:inline; float:right;">$600</p>

            <div style="clear: both"></div>
          <span id="amount">Amount:</span> <span id="valBox">$300</span>
          <button class="button button-small button-royal" id="buttonGo" style="float:right;">
              Go
          </button>
          </div>
          <i class="icon ion-star"></i>
      </ion-content>
    </ion-pane>


    <script>
    function showVal(newVal){
        document.getElementById("valBox").innerHTML="$" + newVal;
    }
    </script>
  </body>
</html>
&#13;
&#13;
&#13;

App.js

&#13;
&#13;
// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });

});
&#13;
&#13;
&#13;

我的angular.js文件

&#13;
&#13;
function StoreController() {
    alert('Its working!');
}
&#13;
&#13;
&#13;

所以当我这样做来测试我的功能时,

它说StoreController功能是不确定的......我希望有人可以帮忙!

1 个答案:

答案 0 :(得分:0)

您需要在下面的html中包含js文件,其中包含app.js

<script src="js/angular.js"></script>

你编写的所有js脚本都需要包含在html中才能工作,与css一样。