angularJs中的注射器模块误差

时间:2016-03-01 11:02:46

标签: angularjs

我得到“未捕获的错误:[$ injector:modulerr]”。任何人都可以帮我解决这个问题。我的代码如下..

<!DOCTYPE html>
<html>
<head>
<style>
    body {
  max-width: 32em;
  margin: 1em auto 0;
}

img { width: 30px; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script>
// https://angular-ui.github.io/

// setup app and pass ui.bootstrap as dep
var myApp = angular.module("angularTypeahead", ["ui.bootstrap"]);

// define factory for data source
myApp.factory("States", function(){
  var states = ["Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Dakota", "North Carolina", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"];

  return states;

});

// setup controller and pass data source
myApp.controller("TypeaheadCtrl", function($scope, States) {
    console.log("hello");
    $scope.selected = undefined;

    $scope.states = States;

});
</script>
</head>
<body>
<div ng-app="angularTypeahead">
    <div class="container-fluid" ng-controller="TypeaheadCtrl">
        <h2><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/15309/angular-logo.svg" alt="Angular.js Logo"> Angular.js Typeahead</h2>
        <div class="form-group">
          <label for="states">Search for US States</label>
            <input name="states" id="states" type="text" placeholder="enter a state" ng-model="selected" typeahead="state for state in states | filter:$viewValue | limitTo:8" class="form-control">
        </div>
    <button class="btn btn-success" type="submit">Submit</button>
    </div>
</div>
</body>
</html>

我在哪里做错了吗?我从codepen获得了这段代码。它在那里运行得很好。但它没有在我的本地运行

0 个答案:

没有答案