I can not get ui.router to load the component on index.html through the local host or otherwise:
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/angular-ui-router@0.3.1/release/angular-ui-router.js"></script>
<script src="js/components.js"></script>
<body ng-app="myApp">
<div>
<ui-view></ui-view>
</div>
components.js
var app = angular.module('myApp', ['ui.router']);
app.config(function($stateProvider) {
var mainState ={
name: 'main',
url: '',
component: 'home',
resolve: {
data: function(Resource) {
console.log(Resource.test())
return Resource.test()
}
}
}
$stateProvider.state(mainState);
})
app.service('Resource', function ($http) {
var service = {
test: function() {
return "Hello world"
}
}
return service;
})
app.component('home', {
bindings: { data: '<'},
template: "<p>{{data}}</p>",
controller: function () {
console.log(this)
}
})
"Hello world" loads, like data, when I do $ http through the service. But it is not passed to the component. Any thoughts?
source
share