-
-
Save manish-shrivastava/2f779283132b2cdcd8cb5299fc9ed3be to your computer and use it in GitHub Desktop.
Revisions
-
manish-shrivastava renamed this gist
Dec 21, 2016 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -69,7 +69,7 @@ App.FavoritesRoute = Ember.Route.extend({ ``` - Using Ember Data is not mandatory. Model could be a plain JSON object: ``` js App.UserRoute = Ember.Route.extend({ model: function(params) { -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -68,6 +68,19 @@ App.FavoritesRoute = Ember.Route.extend({ }); ``` - Using Ember Data is not mandatory. Model could be a plain JSON object: - ``` js App.UserRoute = Ember.Route.extend({ model: function(params) { return { first_name: "Eric", last_name : "Sipple" }; } }); ``` ### View - Views are for **Creating reusable components** and **Setting up logic to handle events.** -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -102,7 +102,7 @@ App.UserController = Ember.ObjectController.extend({ }); ``` - May contain property and observer declarations (attention to get/set calls). Controller property monitors enumerated values and evaluate associated function. Observer executes their action respectively: ``` js App.NumberController = Ember.ObjectController.extend({ @@ -122,6 +122,8 @@ App.NumberController = Ember.ObjectController.extend({ ``` - Example above will make this template alive: ``` handlebars {{input type="text" value=number size="50"}} x2 = {{timesTwo}} ``` -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -102,15 +102,24 @@ App.UserController = Ember.ObjectController.extend({ }); ``` - May contain property and observer declarations (attention to get/set calls): ``` js App.NumberController = Ember.ObjectController.extend({ number: 1, timesTwo: function() { return Number(this.get('number')) * 2; }.property('number'), fullName: function() { // Calculate some value return this.get("first_name") + " " + this.get("last_name"); }.property('first_name', 'last_name'), nameChanged: function() { // Execute some action console.log("New name! New name!"); }.observes('first_name', 'last_name') }); ``` ``` handlebars -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,7 +11,7 @@ - Templates are written in Handlebars. - Has a name (file name or `data-template-name` attribute value of `<script>` element). - Backed by a model and auto-updates following model changes. - Can retrieve properties from Model and Controller. - Can nest one another template with `{{outlet}}` expression. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. @@ -24,14 +24,17 @@ </script> ``` - By default Ember will attach `application` template to the document's body element. - Root element could be changed during app creation: ``` js App = Ember.Application.create({ rootElement: '#app' }); ``` - There are partial templates that can be included with `render` Handlebars expression. ### Router - Router recognizes URL, and passes it to a Route object. @@ -51,7 +54,8 @@ App.Router.map(function() { ### Route - Route sets up a Controller and supplies it with a Model. - Tells model which template to show. - Each route has controller and template with the same name. - Routes can implement hooks. - `model` hook can specify what model will be represented to the template by controller. @@ -87,8 +91,8 @@ App.UserController = Ember.ObjectController.extend({ ### Controller - Controller provides Model data to the Template. - Can be used to process Model data for the Template (calculated properties). ``` js App.UserController = Ember.ObjectController.extend({ -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,7 @@ App = Ember.Application.create({ ``` ### Router - Router recognizes URL, and passes it to a Route object. - Translates URL into nested templates. - Keep browser address line updated. -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,7 @@ App = Ember.Application.create({ ``` ### Router - Router recognizes and passes to a Route object. - Translates URL into nested templates. - Keep browser address line updated. -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -97,6 +97,21 @@ App.UserController = Ember.ObjectController.extend({ }); ``` - Attention to the property declaration (`.property()`) ad get/set calls: ``` js App.NumberController = Ember.ObjectController.extend({ number: 1, timesTwo: function() { return Number(this.get('number')) * 2; }.property('number') }); ``` ``` handlebars {{input type="text" value=number size="50"}} x2 = {{timesTwo}} ``` ### Component - Reusable UI element. -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 17 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -66,6 +66,23 @@ App.FavoritesRoute = Ember.Route.extend({ ### View - Views are for **Creating reusable components** and **Setting up logic to handle events.** - Can be used to handle browser events, and send the result to controller: ``` js App.ProfilePhotoView = Ember.View.extend({ click: function(evt) { this.get('controller').send('expandProfilePhoto'); } }); App.UserController = Ember.ObjectController.extend({ actions: { expandProfilePhoto: function() { // Get the expanded picture and display it } } }); ``` ### Controller -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,7 +65,7 @@ App.FavoritesRoute = Ember.Route.extend({ ### View - Views are for **Creating reusable components** and **Setting up logic to handle events.** ### Controller -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 10 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,7 +58,7 @@ App.Router.map(function() { ``` js App.FavoritesRoute = Ember.Route.extend({ model: function() { return this.store.find('project'); } }); ``` @@ -70,7 +70,15 @@ App.FavoritesRoute = Ember.Route.extend({ ### Controller - Template can get properties from controller. - Used to provide the logic used to access data from the Model (e.g. calculated data). ``` js App.UserController = Ember.ObjectController.extend({ fullName: function() { return this.get("first_name") + " " + this.get("last_name"); } }); ``` ### Component -
dreikanter revised this gist
Jan 12, 2015 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,8 +15,6 @@ - Can nest one another template with `{{outlet}}` expression. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. ``` handlebars <script type="text/x-handlebars"> @@ -26,6 +24,14 @@ </script> ``` - By default Ebmer will application template to the document's body element. - Root element could be changed during app creation: `rootElement: '#app'`. ``` js App = Ember.Application.create({ rootElement: '#app' }); ``` ### Router - Translates URL into nested templates. -
dreikanter revised this gist
Jan 12, 2015 . 2 changed files with 107 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,8 @@ - Can nest one another template with `{{outlet}}` expression. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. - By default Ebmer will application template to the document's body element. - Root element could be changed during app creation: `rootElement: '#app'`. ``` handlebars <script type="text/x-handlebars"> @@ -67,6 +69,3 @@ App.FavoritesRoute = Ember.Route.extend({ ### Component - Reusable UI element. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,105 @@ <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <meta content='IE=Edge,chrome=1' http-equiv='X-UA-Compatible'> <meta content='width=device-width, initial-scale=1.0' name='viewport'> <title>Example Angular App</title> <link rel="stylesheet" media="all" href="/assets/bootstrap_and_overrides.css?body=1" /> <link rel="shortcut icon" type="image/x-icon" href="/assets/favicon.ico" /> <script src="/assets/jquery/jquery.js?body=1"></script> <script src="/assets/jquery.js?body=1"></script> <script src="/assets/jquery.ui.touch-punch.js?body=1"></script> <script src="/assets/handlebars.js?body=1"></script> <script src="/assets/ember.js?body=1"></script> <script src="/assets/ember-data.js?body=1"></script> </head> <style> body { padding: 20px; } </style> <body> <script type="text/x-handlebars"> <h1>{{appName}}</h1> <h2>{{title}}</h2> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="projects_list"> <ul> {{#each item in model}} <li>{{#link-to 'project' item.id}}{{item.title}}{{/link-to}}</li> {{/each}} </ul> </script> <script type="text/x-handlebars" data-template-name="list_item"> <li>{{#link-to 'project' item.id}}{{item.title}}{{/link-to}}</li> </script> <script type="text/x-handlebars" data-template-name="project"> <dl> <dt>Title:</dt> <dd>{{model.title}}</dd> <dt>ID:</dt> <dd>{{model.id}}</dd> </dl> </script> <script> var App = Ember.Application.create({ LOG_TRANSITIONS: true }); App.ApplicationRoute = Ember.Route.extend({ setupController: function(controller) { controller.set('title', "Hello world!"); } }); App.ApplicationController = Ember.Controller.extend({ appName: 'My First Example' }); App.Router.map(function() { this.route('projects_list', { path: 'projects' }); this.route('project', { path: 'projects/:project_id' }); }); App.ProjectsController = Ember.Controller.extend({ }); var PROJECTS = [ { id: 1, title: 'Project 1' }, { id: 2, title: 'Project 2' } ]; App.ProjectsListRoute = Ember.Route.extend({ model: function() { return PROJECTS; } }); App.ProjectRoute = Ember.Route.extend({ model: function(params) { if (!PROJECTS[params.project_id]) { return null; } return PROJECTS[params.project_id]; } }); </script> </body> </html> -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 41 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ <!DOCTYPE html> <html> <head> <meta charset='utf-8'> <meta content='IE=Edge,chrome=1' http-equiv='X-UA-Compatible'> <meta content='width=device-width, initial-scale=1.0' name='viewport'> <title>Example Angular App</title> <link rel="stylesheet" media="all" href="/assets/bootstrap_and_overrides.css?body=1" /> <link rel="shortcut icon" type="image/x-icon" href="/assets/favicon.ico" /> <script src="/assets/jquery/jquery.js?body=1"></script> <script src="/assets/jquery.js?body=1"></script> <script src="/assets/jquery.ui.touch-punch.js?body=1"></script> <script src="/assets/handlebars.js?body=1"></script> <script src="/assets/ember.js?body=1"></script> <script src="/assets/ember-data.js?body=1"></script> </head> <body> <script type="text/x-handlebars"> <h1>{{appName}}</h1> <h2>{{title}}</h2> </script> <script> var App = Ember.Application.create({ LOG_TRANSITIONS: true }); App.ApplicationRoute = Ember.Route.extend({ setupController: function(controller) { controller.set('title', "Hello world!"); } }); App.ApplicationController = Ember.Controller.extend({ appName: 'My First Example' }); </script> </body> </html> -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,9 +12,7 @@ - Has a name (file name or `data-template-name` attribute value of `<script>` element). - Backed by a model and auto-updates following model changes. - Can retrieve properties from model and controller. - Can nest one another template with `{{outlet}}` expression. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -11,6 +11,7 @@ - Templates are written in Handlebars. - Has a name (file name or `data-template-name` attribute value of `<script>` element). - Backed by a model and auto-updates following model changes. - Can retrieve properties from model and controller. - Can be nested. - One template can nest only one child template. - Nesting is implemented with `{{outlet}}` expression. -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 9 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,15 @@ - An object that stores data (data persistance layer abstraction). - Templates transforms models into HTML. - Same thing as Rails model. ### Template - Templates are written in Handlebars. - Has a name (file name or `data-template-name` attribute value of `<script>` element). - Backed by a model and auto-updates following model changes. - Can be nested. - One template can nest only one child template. - Nesting is implemented with `{{outlet}}` expression. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. @@ -16,15 +25,6 @@ </script> ``` ### Router - Translates URL into nested templates. -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,6 +5,16 @@ - An object that stores data (data persistance layer abstraction). - Templates transforms models into HTML. - Same thing as Rails model. - Uses `text/x-handlebars` type when defined in `<script>` blocks. - Unnamed script block will be treated as `application` (root) template. ``` handlebars <script type="text/x-handlebars"> <div> {{outlet}} </div> </script> ``` ### Template -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ - An object that stores data (data persistance layer abstraction). - Templates transforms models into HTML. - Same thing as Rails model. ### Template -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,6 +37,14 @@ App.Router.map(function() { - Routes can implement hooks. - `model` hook can specify what model will be represented to the template by controller. ``` js App.FavoritesRoute = Ember.Route.extend({ model: function() { return this.store.find('post'); } }); ``` ### View - ? -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,13 +33,17 @@ App.Router.map(function() { ### Route - An object that tells model which template to show. - Each route has controller and template with the same name. - Routes can implement hooks. - `model` hook can specify what model will be represented to the template by controller. ### View - ? ### Controller - Template can get properties from controller. - ? ### Component -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ ## Core concepts ### Model @@ -45,3 +45,6 @@ App.Router.map(function() { ### Component - Reusable UI element. --- -
dreikanter revised this gist
Jan 11, 2015 . 1 changed file with 32 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,23 @@ Core concepts: ### Model - An object that stores data (data persistance layer abstraction). - Templates transforms models into HTML. ### Template - Templates are written in Handlebars. - Has a name (file name or `data-template-name` attribute value of `<script>` element). - Backed by a model and auto-updates following model changes. - Can be nested. - One template can nest only one child template. - Nesting is implemented with `{{outlet}}` expression. ### Router - Translates URL into nested templates. - Keep browser address line updated. ``` js App.Router.map(function() { @@ -23,3 +29,19 @@ App.Router.map(function() { this.route('project', { path: '/about' }); }); ``` ### Route - An object that tells model which template to show. ### View - ? ### Controller - ? ### Component - Reusable UI element. -
dreikanter created this gist
Jan 11, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ Core concepts: - Template - Templates are written in Handlebars. - Each template has a name (file name or `data-template-name` attribute value of `<script>` element). - Each template is backed by a model and auto-updates following model changes. - Router - Route - Model - View - Controller ## Router ``` js App.Router.map(function() { this.resource('tasks', function() { this.route('task', { path: '/:task_id' }); }); this.route('user'); this.route('project', { path: '/about' }); }); ```