离子/科尔多瓦应用程序:如何更改在单击按钮另一个模板? [英] Ionic/Cordova App: How to change to another template in button click?

查看:198
本文介绍了离子/科尔多瓦应用程序:如何更改在单击按钮另一个模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发和应用离子,我需要你在点击链接后,它把你带到另一个模板。该模板被称为 area.html 并没有在sidemenu,我说作为一个的状态的它在 app.js 。在这里,你有一些code:

app.js

  .STATE('app.area',{
    网址:/区,
    观点:{
      menuContent:{
        templateUrl:模板/ area.html
        控制器:'AreaCtrl
      }
    }
  });

firsttemplate.html

 <离子查看查看标题=第一个模板>
  <离子内容类=背景>    <按钮类=按钮,按钮呈阳性
            NG-点击=changeToArea()>当前的位置< /按钮>  < /离子含量>
< /离子视图>

controller.js

  .controller('FirstTempCtrl',函数($范围){      $ scope.changeToArea =功能(){
      的console.log(区域Func键);
      window.location的=#/应用/ area.html
    })

的事情是,当你在按钮单击它带你到另一个模板,以

  $ urlRouterProvider.otherwise('/应用/日志');

app.js 什么,我要加载的 area.html


解决方案

 了window.location =#/应用/ area.html

将重新加载应用程序,因此所有的控制器

您需要使用的UI路由器与为例: $ state.go('app.area');

I am developing and app in Ionic and I need that after you click in button it takes you to another template. This template is called area.html and is not in the sidemenu, I added as a state of it in app.js . Here you have some code:

app.js

.state('app.area', {
    url: "/area",
    views: {
      'menuContent': {
        templateUrl: "templates/area.html",
        controller: 'AreaCtrl'
      }
    }
  });

firsttemplate.html

<ion-view view-title="First Template">
  <ion-content class="background">

    <button class="button button-positive"
            ng-click="changeToArea()">Current Position</button>

  </ion-content>
</ion-view>

controller.js

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

      $scope.changeToArea = function() {
      console.log("Area Func");
      window.location = "#/app/area.html";
    })

The thing is that when you click in the button it take you to another template, to the :

$urlRouterProvider.otherwise('/app/log');

in the app.js and what I want to load is area.html

解决方案

 window.location = "#/app/area.html"; 

will reload your app and therefore all controllers

you need to use ui-router with for exemple : $state.go('app.area');

这篇关于离子/科尔多瓦应用程序:如何更改在单击按钮另一个模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆