试图在html中显示范围 - angularJS/ionic

试图在html中显示范围 - angularJS/ionic

问题描述:

试图在html中显示范围 - angularJS/ionic 尝试在我的网页上显示标题,但没有显示任何内容。我对角和离子框架相当陌生。如果任何人都可以指出我做错了什么,这将有助于一吨!试图在html中显示范围 - angularJS/ionic

这里是我的控制器JS:

angular.module('MyApp', []) 

.controller('TodoCtrls', function($scope) { 


    $scope.tasks = [ 
    { title: 'Collect coins' }, 
    { title: 'Eat mushrooms' }, 
    { title: 'Get high enough to grab the flag' }, 
    { title: 'Find the Princess' } 
    ]; 
}) 

而且我的html:

<html ng-app="MyApp"> 

<ion-header> 
    <ion-navbar> 
    <ion-title>Courses</ion-title> 
     <h1 class="title">Todo</h1> 
    </ion-navbar> 
</ion-header> 

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

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script> 



<body ng-app="MyApp" ng-controller="TodoCtrls"> 
    <ion-content> 
    <ion-list> 
     <ion-item ng-repeat="task in tasks"> 
     <h1>{{task.title}}</h1><br> 
     </ion-item> 
    </ion-list> 
    </ion-content> 
</body> 

</html> 
+0

你得到它的工作? :) –

欢迎SO。您的代码基本上是好的,但有两个问题:

  1. ion-header标签应该是body元素
  2. 我假设你只是包括在此文件中进行测试的angular.min.js内,所以你不需要一些花哨的东西。但脚本需要按照正确的顺序加载。我会在关闭</body>标签之前放置它们,然后切换订单,以便在控制器之前加载Angular。

当我I change this in your example, it seems to work。离子不包括在任何地方,所以你当然不会得到样式,但是列表被渲染。

+0

所以我改变了它,我仍然没有显示任何内容。有没有办法可以向我发送代码片段? –

+0

当然@KateWatkins http://embed.plnkr.co/AdJY6wBCQszF6HRgOtyz/ –