Skip to content

Instantly share code, notes, and snippets.

@itsvicsoto
Last active December 15, 2018 17:54
Show Gist options
  • Save itsvicsoto/f34e77045ea1a1fe71a7 to your computer and use it in GitHub Desktop.
Save itsvicsoto/f34e77045ea1a1fe71a7 to your computer and use it in GitHub Desktop.
[cheatsheet] Angular 1.3.9

[cheatsheet] Angular 1.3.9

  ;
(function() {
  'use strict';

  angular.module('testModule', [])

  .directive('testDirective', [
    function(EccAPI) {
      return {
        restrict: 'E',
        scope: {
          test: '@'
        },
        templateUrl: '/component-tpl.html',
        bindToController: true,
        controllerAs: 'testdir',
        controller: function($scope, $element, $attrs, $transclude) {
          this.clickBtn = function() {
            console.log($scope);
            console.log('woah');
          }
        },
        link: function($scope, $element, $attrs) {

        }
      }
    }
  ])
}());
myApp.factory('myFactory', ['$rootScope', function ($rootScope) {
    $rootScope.$emit("myEvent", myEventParams);
}]);

ng-repeat

ng-repeat that will display loading or if empty set of data.

<ul>
  <li ng-if="outstanding == undefined">
    <i class="fa fa-refresh fa-spin"></i> Loading...
  </li>
  <li ng-if="outstanding.items.length === 0">
    Nothing is Available...
  </li>
  <li ng-if="item.type != 'script'" ng-repeat="item in outstanding.items">
    <img placeholdit width="60" height="60" size="60x60" ng-src="item.url">
    <div class="item-meta">
      <h4>{{ item.name }}</h4>
      <span class="description">
       <p>{{ item.description }}</p>
      </span>
    </div>
    <div class="actions">
      <button ng-click="download(item, outstanding.hashToken)">
        <i class="fa fa-cloud-download"></i> Button Click
      </button>
    </div>
  </li>
</ul>

[cheatsheet] jQuery

Iterating something

  $.each('.mark-solo', function(index) {
    selectedNotification.push($(this).data('activityId'));
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment