[Angularjs] how to use ‘angular-paginate-anything’ pagination module

Client-side Aangularjs Install: bower install angular-paginate-anything –save Angularjs: app.js angular.module(‘myModule’, [‘bgf.paginateAnything’]); blog.controller.js [js] class BlogCtrl { constructor(Auth, Blog, $state, $stateParams, $http, $scope, $location, socket) { this.errors = {}; this.success = {}; this.submitted = false; this.Auth = Auth; this.Blog = Blog; this.$state = $state; this.$stateParams = $stateParams; this.blogs = []; $scope.url = ‘/api/blogs’; $scope.perPage = parseInt($location.search().perPage,…

Read More

[bootstrap-markdown] show and hide markdown editor programmatically

html: [html] Edit [/html] Angularjs: [js] editComment(comment){ var self = this; var editor = angular.element($(`#${comment._id}`)); editor.markdown({autofocus: true, savable: true, hideable:true, onSave: function(e) {//e: markdown editor self.Blog.saveComment({ id: self.blog._id, comment_id: comment._id, content: e.getContent() }).$promise .then(() => { //angular.element($(‘.md-editor’)).children(‘.md-footer’).html(‘Comment is updated.’); var el = angular.element($(‘.md-editor’)).parents(‘.panel’); el.css( “background-color”, “#ffeeff” ); setTimeout(() => { el.css( “background-color”, “#ffffff” ); },…

Read More

[mongoose] update and delete embedded document in array

Update: var comment = blog.comments.id(comment_id); comment.author = ‘Bruce Wayne’; blog.save(function (err) { // emmbeded comment with author updated }); Delete: Blog.findByIdAndUpdateAsync(blogId, { $pull: { comments: {_id: commentId}} }) .then(blog => { res.status(200).json(‘Comment is deleted successfully.’); }) .catch(err => { console.error(err); res.status(500).json(err.message || err); });

Read More

angular-fullstack generated code upgrade with Babel 6

Install  Babel 6 related packages: npm install –save-dev babel-register npm install –save-dev babel-plugin-add-module-exports npm uninstall –save-dev babel-core npm install –save-dev babel-core npm install babel-preset-es2015 Create .babelrc file: vi .babelrc { “presets”: [“es2015”], “plugins”: [“babel-plugin-add-module-exports”] } Chanage server/index.js file: vi server/index.js if (env === ‘development’ || env === ‘test’) { // Register the Babel require hook…

Read More

How do I make a “public static field” in an ES6 class?

class Agent { static get CIRCLE() { return 1; } static get SQUARE() { return 2; } } console.log(Agent.CIRCLE); // 1 class Shape { } Shape.CIRCLE = 1; Shape.SQUARE = 2; console.log(Shape.CIRCLE); // 1 class MyClass { static get MY_CONST() { delete MyClass.MY_CONST; return (MyClass.MY_CONST = ‘string’); } static set MY_CONST(value) { delete MyClass.MY_CONST; MyClass.MY_CONST…

Read More

ECMAScript 6 Tutorial, Setting up Babel 6 – Babel compile it to run in current browser

현재의 브라우저는 ES6(ECMAScript 6) 자바스크립트를 지원하지 않는다. ES6 코드는 컴파일러(트랜스파일러)를 사용해 현재의 브라우저에서 돌아가는 코드로 변환해야 한다. 바벨(Babel)이 ES6 코드를 컴파일하는 사실상의 표준이 되었다. 아래 투토리얼은 Babel를 이용해 ES6 어플리케이션을 개발하고 실행하기 위한 개발환경을 설정해 본다. ** Babel 6 버전이 설치된 경우, 변환작업이 진행되지 않을 수 있다. Babel 6에서 설정이 변경되어 아래를 참조하여 설정을 해야…

Read More