Ionic framework 无法显示模态
我目前面临的问题是在ionic(1.7.14)上显示模态。我创建了一个简单的应用程序,其中一个页面包含一个列表和一个添加按钮。在这个按钮上,我想显示一个在任务列表中添加新元素的模式 这是我的示例代码 modal.html(在www/templates文件夹中创建的新文件) Index.htmlIonic framework 无法显示模态,ionic-framework,modal-dialog,Ionic Framework,Modal Dialog,我目前面临的问题是在ionic(1.7.14)上显示模态。我创建了一个简单的应用程序,其中一个页面包含一个列表和一个添加按钮。在这个按钮上,我想显示一个在任务列表中添加新元素的模式 这是我的示例代码 modal.html(在www/templates文件夹中创建的新文件) Index.html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport"
<!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">
<!-- 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/controller.js"></script>
</head>
<!--<body ng-app="starter">-->
<body ng-app="starter">
<ion-header-bar class="bar-positive">
<h1 class="title">Todo list</h1>
<div class="buttons">
<button class="button icon ion-plus" ng-click="openModal()"> </button>
</div>
</ion-header-bar>
<ion-content>
<ion-list ng-controller="ToDoListCtrl">
<ion-item ng-repeat="item in toDoListItems">
{{item.task}}
</ion-item>
</ion-list>
</ion-content>
</body>
</html>
我试图在打开模式之前添加console.log('test'),并且,log命令没有显示在控制台中…问题是您将控制器连接到
中的视图,并且按钮是以前创建的,因此它不起作用。在创建按钮之前,您必须添加ng controller=“ToDoListCtrl”
。您已经将控制器包括到列表项中,但您正在尝试调用列表外控制器中的函数。
所以试试这个
<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">
<!-- 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/controller.js"></script>
</head>
<!--<body ng-app="starter">-->
<body ng-app="starter">
<ion-header-bar class="bar-positive">
<h1 class="title">Todo list</h1>
<div class="buttons">
<button class="button icon ion-plus" ng-click="openModal()"> </button>
</div>
</ion-header-bar>
<ion-content ng-controller="ToDoListCtrl">
<ion-list>
<ion-item ng-repeat="item in toDoListItems">
{{item.task}}
</ion-item>
</ion-list>
</ion-content>
</body>
</html>
任务清单
{{item.task}
您的意思是在body标签中?
<!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">
<!-- 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/controller.js"></script>
</head>
<!--<body ng-app="starter">-->
<body ng-app="starter">
<ion-header-bar class="bar-positive">
<h1 class="title">Todo list</h1>
<div class="buttons">
<button class="button icon ion-plus" ng-click="openModal()"> </button>
</div>
</ion-header-bar>
<ion-content>
<ion-list ng-controller="ToDoListCtrl">
<ion-item ng-repeat="item in toDoListItems">
{{item.task}}
</ion-item>
</ion-list>
</ion-content>
</body>
</html>
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
})
<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">
<!-- 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/controller.js"></script>
</head>
<!--<body ng-app="starter">-->
<body ng-app="starter">
<ion-header-bar class="bar-positive">
<h1 class="title">Todo list</h1>
<div class="buttons">
<button class="button icon ion-plus" ng-click="openModal()"> </button>
</div>
</ion-header-bar>
<ion-content ng-controller="ToDoListCtrl">
<ion-list>
<ion-item ng-repeat="item in toDoListItems">
{{item.task}}
</ion-item>
</ion-list>
</ion-content>
</body>
</html>