Angular - UI.Router lädt Komponente @ nic

Ich kann ui.router nicht dazu bringen, eine Komponente in index.html über einen localhost oder auf andere Weise zu laden:

index.html

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
    <script src="//unpkg.com/[email protected]/release/angular-ui-router.js"></script> <!-- used to route views -->
    <script src="js/components.js"></script>

    <body ng-app="myApp">
    <div> <!-- main content -->
         <ui-view></ui-view>   <!-- this directs ui-router to put the home view here-->
    </div>

components.js

    var app = angular.module('myApp', ['ui.router']); //makes a call to the Angular API to create our app, configured with the ui.router plug-in
    //configure our view router
    app.config(function($stateProvider) { 
      //create our different views as objects
      var mainState ={
        name: 'main', //name of the object
        url: '', //url to point to, or that causes this view to be triggered
        component: 'home', //component that works with the data, loads the template
        resolve: { //data to bind to our component
          data: function(Resource) {
            console.log(Resource.test()) //returns "Hello World"
            return Resource.test() 
          }
        }
      }
      //call the states
      $stateProvider.state(mainState); 
    })
    app.service('Resource', function ($http) {
      var service = {
       test: function() {
          return "Hello world"
        }
      }
      return service;
    })
    app.component('home', {
      bindings: { data: '<'}, //make the data we loaded into the view from the factory available to this component
      template: "<p>{{data}}</p>", //this is the html that we will plug our data into
      controller: function () {
        console.log(this) //does not call
      }
    })

"Hallo Welt" wird geladen, ebenso wie Daten, wenn ich $ http durch den Dienst bekomme. Es wird jedoch nicht an die Komponente übergeben. Irgendwelche Gedanken?

Antworten auf die Frage(4)

Ihre Antwort auf die Frage