2015-12-02 45 views
4

我想使用離子框架顯示嵌入按鈕的自定義通知(就像音樂播放器控件一樣),允許用戶在點擊通知時有選擇。帶離子框架的自定義通知模板

我找不到任何有關這方面的官方(或非官方)文檔,我甚至不知道它是否可行。

有沒有人成功地創建了具有離子框架的自定義通知模板?

回答

0

我對自定義模板使用了ionicPopup。

這裏是一個CodePen:http://codepen.io/nicon-dev/pen/EPYeGJ

或:

angular.module('ionicApp', ['ionic']) 
 

 
.controller('MyCtrl', function($scope, $ionicPopup) { 
 

 
    $scope.openPopup = function() { 
 

 
    var customTemplate = 
 
     '<ion-toggle>enable</ion-toggle>' + 
 
     '<label class="item item-input"><input type="text" placeholder="your address"></label>'; 
 

 
    $ionicPopup.show({ 
 
     template: customTemplate, 
 
     title: 'alternative location', 
 
     subTitle: 'select this option if GPS is unavailable', 
 
     buttons: [{ 
 
     text: 'Cancel', 
 
     //type: 'button-positive', 
 
     onTap: function(e) { 
 

 
     } 
 
     }, { 
 
     text: '<b>Save</b>', 
 
     type: 'button-positive', 
 
     onTap: function(e) { 
 
      
 
     } 
 
     }] 
 
    }); 
 

 
    } 
 
});
<html ng-app="ionicApp"> 
 

 
<head> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> 
 

 
    <title>Ionic Pull to Refresh</title> 
 

 
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet"> 
 
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script> 
 

 
</head> 
 

 
<body ng-controller="MyCtrl"> 
 

 
    <ion-header-bar class="bar-positive"> 
 
    <h1 class="title">Awesome App</h1> 
 
    </ion-header-bar> 
 

 
    <ion-content class="padding"> 
 
    <button class="button button-balanced" ng-click="openPopup()">open popup</button> 
 
    </ion-content> 
 

 
</body> 
 

 
</html>

$ ionicPopup文檔:HERE

希望這有助於。

+0

感謝您的回答,但不幸的是,這不是我正在尋找的。 我想要實現的是顯示一個嵌入按鈕的原生通知,而不是一個應用內彈出窗口。 你可以看到我想要做的一個例子[這裏](http://media02.hongkiat.com/android-notification-features/dismiss-all-notifications.jpg)(「立即解僱」按鈕) –

+0

你正在尋找的是推送消息。看一看[Ionic Push Service](http://docs.ionic.io/docs/push-overview)作爲起點 – Nico

+0

我知道這是我正在尋找的服務,我在這裏問的是如何設計一個通知,使其具有通向不同行爲的按鈕。我還沒有找到任何有關這方面的文件。 –