Add server error messages to all views with directive


#1

Hi

I created a directive that shows server errors (40* or 50*). I implemented it as a http error interceptor wich sets a small box visible. I am using the tabs starter project and I have the following the index.html structure:

 <body ng-app="cashless" animation="slide-left-right-ios7">
    <!-- 
      The nav bar that will be updated as we navigate between views.
    -->
    <ion-nav-bar class="bar-stable nav-title-slide-ios7">
      <ion-nav-back-button class="button-icon icon ion-chevron-left">
      </ion-nav-back-button>
    </ion-nav-bar>
    <!-- 
      The views will be rendered in the <ion-nav-view> directive below
      Templates are in the /templates folder (but you could also
      have templates inline in this html file if you'd like).
    -->
    <ion-nav-view></ion-nav-view>
  </body>

My question, do I have to add the directive that displays the error message on every view? I tried to put it below the tag or below the in the index file but it does not show up.

Any other ideas?

BR, Rene


#2

Hmm, do you mind putting some sample code? A codepen or plnkr. This way we could better help you out.


#3

Have you see this? http://codepen.io/ionic/pen/pEter

It’s a great way to show an error from a HTTP call.


Which is the best method to use a global directive to manage and display error message?
#4

Hex Calendee

THX a lot. Looks perfect!


#5

Do work on Android if into css there is top: 44px;?


#6

It’s a beauty method to show error. But How to use with directive or decorator? There is angular-toast plugin: https://github.com/jirikavi/AngularJS-Toaster