Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div data-ng-app="App" data-ng-controller="AppCtrl">
    <h2>Angular Images with ng-src fallback</h2>  
  <hr>
  <p>- IF All image ng-src ok THEN first image displayed</p>
    <img ng-src="{{('https://www.w3.org/html/logo/downloads/HTML5_Badge_256.png') || ('https://s3-us-west-2.amazonaws.com/s.cdpn.io/68939/angular-logo.png')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
  <hr>
  <p>- IF First image ng-src 404 THEN onError image displayed. Even though second image is ok, the first 404 image triggers the onError. Angular evaluates image as truth-y, and passes error.</p>
    <img ng-src="{{('404.png') || ('https://s3-us-west-2.amazonaws.com/s.cdpn.io/68939/angular-logo.png')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
  <hr>
  <p>- IF First image ng-src blank THEN second Angular image displayed. First Angular ng-src evaluated as false, and login continues to OR parameter for second ng-src.</p>
    <img ng-src="{{('') || ('https://s3-us-west-2.amazonaws.com/s.cdpn.io/68939/angular-logo.png')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
  <hr>
  <p>- IF Second image ng-src 404 THEN first image src displayed. Once first ng-src is found truth-y, image is used.</p>
    <img ng-src="{{('https://www.w3.org/html/logo/downloads/HTML5_Badge_256.png') || ('404.png')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
  <hr>
  <p>- IF Both images ng-src 404 THEN onError image src displayed</p>
    <img ng-src="{{('404.png') || ('404.png')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
  <hr>
  <p>- IF Both images ng-src are blank THEN no image src displayed (images would display below this paragraph). Both ng-src are evaluated as false, and no onError triggered by a 404, so no image displayed at all.</p>
    <img ng-src="{{('') || ('')}}" onerror="this.src='https://placehold.it/200?text=on+Error'" />
 </div>
              
            
!

CSS

              
                body    { font-family: Helvetica, Arial, sans-a }

%rounded-top {
  -webkit-border-top-right-radius: 3px;
   -webkit-border-top-left-radius: 3px;
      -moz-border-radius-topright: 3px;
       -moz-border-radius-topleft: 3px;
          border-top-right-radius: 3px;
           border-top-left-radius: 3px;
}


[data-tab-menu]{
  position:relative;
  z-index:1;
  li { float:left; }
  a  { 
    @extend %rounded-top;
    display:block; 
    padding:10px 30px; 
    border:1px solid #ccc; 
    background:#f1f1f1; 
    margin-right:-1px;
  }
  a.active { border-bottom:1px solid #fff; background:#fff; }  
}

section { 
  position:relative;
  float:left;
  clear:left;
  display:block; 
  margin-top:-1px;
  width:100%; 
  min-height:250px; 
  border:1px solid #ccc; 
  background:#fff;
  padding:30px;
  
-webkit-border-radius: 5px;
   -moz-border-radius: 5px;
        border-radius: 5px;  
-webkit-border-top-left-radius:0;
   -moz-border-radius-topleft:0;
       border-top-left-radius:0;  
  
-webkit-box-shadow: 0px 5px 10px -3px rgba(0, 0, 0, 0.2);
-moz-box-shadow:    0px 5px 10px -3px rgba(0, 0, 0, 0.2);
box-shadow:         0px 5px 10px -3px rgba(0, 0, 0, 0.2);
}
/*h2  { float:left; margin-right:-100%;}
p   { float:left; clear:left; margin-right:-100%; }
 img { float:right; width:200px; height:auto;} */
img {max-width: 200px; height: auto; padding-bottom: 20px;}
img + p {
  margin-top:50px;
} 
              
            
!

JS

              
                console.clear();
//   Includes:

var app = angular.module('App',[])
  .controller('AppCtrl',['$scope',function($scope){
    $scope.ui = {};
    $scope.ui.tabview = 'tab1.html';
  }])

              
            
!
999px

Console