Skip to content

Instantly share code, notes, and snippets.

View kikill95's full-sized avatar

Kirill Gusyatin kikill95

View GitHub Profile
@kikill95
kikill95 / directive.js
Created April 4, 2016 18:53
Custom directive
angular.module('app', [])
.directive('ourDirective', function() {
return {
restrict: 'E',
transclude: false,
replace: true,
template: '<div>template</div>',
// templateURL: '../path/to/file.html',
// or function that returns the way for template
scope: {
@kikill95
kikill95 / gulpfile.js
Created March 20, 2016 20:03
browserify
var gulp = require('gulp'),
concat = require('gulp-concat'),
ngAnnotate = require('gulp-ng-annotate'),
uglify = require('gulp-uglify'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
minifyCss = require('gulp-minify-css'),
del = require('del'),
imagemin = require('gulp-imagemin'),
sourcemaps = require('gulp-sourcemaps'),
<ion-navbar *navbar>
<ion-title>
{{getChosenVideo().title || 'Holograms'}}
</ion-title>
</ion-navbar>
<ion-content class="home">
<ion-card *ngFor="#video of video.getVideos()">
<ion-card-header (click)="chooseVideo(video);">
{{video.title}}
import {Page} from 'ionic-framework/ionic';
import {VideoService} from '../../services/videos';
@Page({
templateUrl: 'build/pages/home/home.html',
providers: [VideoService]
})
export class HomePage {
chosenVideo: any;
constructor(private video: VideoService) {
import {Injectable} from 'angular2/core';
@Injectable()
export class VideoService {
getVideos() {
let videos = [
{
title: 'Canned Lightning',
src: 'vids/canned_lightning.mp4'
},
@kikill95
kikill95 / app.ts
Last active March 17, 2016 20:49
Klim
import {App, Platform} from 'ionic-framework/ionic';
import {HomePage} from './pages/home/home';
@App({
template: '<ion-nav [root]="rootPage"></ion-nav>',
config: {} // http://ionicframework.com/docs/v2/api/config/Config/
})
export class MyApp {
rootPage:any = HomePage;
@kikill95
kikill95 / forEach.js
Created February 23, 2016 15:01
forEach for NodeList
// forEach method, could be shipped as part of an Object Literal/Module
var forEach = function (array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]); // passes back stuff we need
}
};
// Usage:
// optionally change the scope as final parameter too, like ECMA5
var myNodeList = document.querySelectorAll('li');
app.filter('l10n', function() {
// In the return function, we must pass in a single parameter which will be the data we will work on.
// We have the ability to support multiple other parameters that can be passed into the filter optionally
return function(input, key) {
// imagine that we have some variables with parsed JSONs
/* var JSONS = {
'ru': ruJSON,
'ua': uaJSON,
@kikill95
kikill95 / index.js
Created January 30, 2016 15:57
electron's example; part 1
var app = require('app'),
browserWindow = require('browser-window'),
mainWindow = null;
app.on('window-all-closed', function() {
app.quit();
});
app.on('ready', function() {
// real example
$ionicLoading.show();
API.post(url, postObject, headers).then(() => {
$state.go(homeStateName);
$ionicPopup.alert({
template: 'Some text'
});
}).then($ionicLoading.hide).catch($ionicLoading.hide);