热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

角url配置没有使用ionic框架-Angularurlconfigisnotworkingwithionicframework

IamtryingtogetmydashboardviewfromtemplatefolderwhenIamloadingmyapp.IamusingIonic

I am trying to get my dashboard view from template folder when I am loading my app. I am using Ionic frame work.

我在加载我的应用程序时,试图从模板文件夹中获取仪表板视图。我正在使用Ionic frame工作。

My index

我的索引

  


  
    

Recharge Plans

My app.js

我app.js

    angular.module('starter', ['ionic','starter.controller','starter.service'])

.config(function($stateProvider, $urlRouterProvider) {

$stateProvider
  .state('dash', {
    url: '/dash',
    views: {
      'dash': {
        templateUrl: '/templates/dash.html',
        controller: 'DashCtrl'
      }
    }
  });
$urlRouterProvider.otherwise('/dash');
});

My controller.js

我controller.js

    angular.module('starter.controller',[])

.controller('DashCtrl', function($scope) {
alert("ok");
})

In 'www\templates' I have a file named dash.html.

在“www\模板”中,我有一个名为dash.html的文件。

My dash.html is

我的短跑。html是


  
        

But when i hit 'file:///C:/Users/Sanjeev/RechargePlans/www/index.html' in browser then it renders me to 'file:///C:/Users/Sanjeev/RechargePlans/www/index.html#/dash' with a blank view .

但当我点击“文件:///C:/用户/Sanjeev/RechargePlans/www/index”时。在浏览器里的html,然后它呈现给我文件:///C:/用户/Sanjeev/RechargePlans/www/index。一个空白的视图。

What I miss??

我错过什么吗? ?

2 个解决方案

#1


1  

If you are going to name your views with Ionic then your ion-view tab HTML needs to look like this:

如果你想用Ionic命名你的视图,那么你的ion-view标签HTML应该是这样的:


Usually with Ionic apps you have a root state and everything stems off that, so:

通常在Ionic应用中,你会有一个根状态,一切都源于此,所以:

app.js file:

app.js文件:

angular.module('starter', ['ionic','starter.controller','starter.service'])

    .config(function($stateProvider, $urlRouterProvider) {

        $stateProvider
            .state('root', {
                url: '/',
                templateUrl: '/templates/tabs.html',
                controller: 'rootCtrl'
                }
             });
            .state('root.dash', {
                url: '/dash',
                views: {
                    'dash': {
                        templateUrl: '/templates/dash.html',
                        controller: 'DashCtrl'
                     }
                }
             });
         $urlRouterProvider.otherwise('/dash');
     });

index.html:

index . html:


tabs.html:

tabs.html:


In any case, if you are naming your views them your ion-view HTML tag needs to have a name attribute with the name of the view in it.

在任何情况下,如果您要为视图命名,那么您的ion-view HTML标记需要有一个名称属性,其中包含视图的名称。

Hope this helps

希望这有助于

#2


1  

you should not run ionic app by "file:///C:/Users/Sanjeev/RechargePlans/www/index.html". you should be using ionic cli tool to run your ionic project. Go to cmd > navigate to your project folder and than run ionic serve and you will be able to see output.

你不应该使用“file:///C:/Users/Sanjeev/RechargePlans/www/index.html”来运行ionic app。您应该使用ionic cli工具来运行您的ionic项目。转到cmd >导航到您的项目文件夹,然后运行ionic服务,您将能够看到输出。


推荐阅读
author-avatar
开心宝2502869253
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有