Sharing Data Between Controllers
lessonDuration 5m 13sFree
If AngularJS Controllers are the glue of an application, how do they communicate and pass data around? This introduction to service factories will shed some light on that question.
Browse
Find courses, lessons, articles, talks, and podcasts.
134 results for "angularjs"
Showing 121–134 · Page 6 of 6
lessonDuration 5m 13sFree
If AngularJS Controllers are the glue of an application, how do they communicate and pass data around? This introduction to service factories will shed some light on that question.
lessonDuration 1m 11sFree
Controllers are the 'glue' of an AngularJS application. They connect your markup with your data and act as a sort of switchboard.
lessonDuration 4m 53s
In this lesson we will add Server Side Rendering to our application using Angular Universal. We'll build a simple Express application and see how Angular Universal builds and renders our app on the server. Since Angular CLI v6 we can simple run `ng generate universal --clientProject store`, where `store` is the name of our app. In `angular.json` in the `architect.server` object we define a `configurations` object, to make sure the correct environment gets copied on a production build. To make Angular Universal with lazy loaded modules we need to add the `ModuleMapLoaderModule` to `AppServerModule`, which we get after installing ` @nguniversal/module-map-ngfactory-loader` from npm. ``` npm install --save @nguniversal/module-map-ngfactory-loader @nguniversal/express-engine ``` In the project root we implement a `server.ts` and define our simple express server. When we run the new server we see that the app gets rendered before it hits the browser.
lessonDuration 26s
A default Angular application ships with two default environment files that can store constants that are different for each environment, one for development and the other for production. We will define the `apiUrl` constant in both development and production environments. The value for development is `http://localhost:3000/api` and the value for production is `https://egghead-products-api.now.sh/api` . In `angular.json` we can find a `configurations` object where our `production` build is defined. We can see that in a production build, the `environment.prod.ts` will replace `environment.ts`. [Link to product api used in lessons](https://github.com/beeman/egghead-products-api)
lessonDuration 40s
The default Angular CLI configuration generates components that consist of 4 files. The component class, an HTML template, a stylesheet and a spec file that contains the unit test. In order to keep our components concise we update our `AppComponent` and move the template and style from an external file to inline. This allows us to delete the 2 external files. We can configure our project to generate the template and the style 'inline' by default. To do this we run the commands: ``` ng config schematics.@schematics/angular.component.inlineStyle true ng config schematics.@schematics/angular.component.inlineTemplate true ``` The changes are made to `angular.json` in the project root.
lessonDuration 3m 39sFree
ng-html2js takes .html templates and converts them into strings stored in AngularJS's template cache. This allows you to bundle all of your templates into a single JavaScript file for simpler deployment and faster loading. John walks through using ng-html2js in the terminal to show what it does, but to integrate with either [gulp](https://www.npmjs.com/package/gulp-ng-html2js) or [grunt](https://www.npmjs.com/package/grunt-html2js), use the tool specific module.
lessonDuration 4m 48sFree
ngMessages works great with AngularJS's ngAnimate and makes the appearance of your messages more awesome.
lessonDuration 5m 33sFree
AngularJS's two-way binding is one of the "killer features" of the framework. The problem is that too many bindings can cause performance issues! Many times, all you need to do is bind a single time to get the data to display, and don't need dynamic two-way binding. In Angular 1.3, they've added new syntax to enable one-time data bindings.
lessonDuration 6m 32sFree
With AngularJS's $scope.$watch, you are able to monitor scope values for changes. This can be useful for validation of user input, as an example.
lessonDuration 4m 1sFree
In his debut lesson, Trevor **test drives** the transformation of a response from an external REST service using the the `transformResponse` option of AngularJS's `$http` service.
lessonDuration 6m 16sFree
In this lesson Trevor will show you how to transform your requests using AngularJS's $http service's transformRequest option and TDD. This allows you to keep your applications domain clean when integrating with third party APIs.
lessonDuration 4m 35sFree
In his debut egghead.io lesson, Joel will show you how to get setup and running with ui-router, an alternative to AngularJS's default routing module.
lessonDuration 1m 50sFree
AngularJS's $routeProvider has a very basic api for defining your application's routes. $routeProvider.when() is used to match a url pattern to a view while $routeProvider.otherwise() is used to render a view when there is no match to a url pattern.
lessonDuration 3m 3sFree
AngularJS's ngView is a directive that complements the $route service by including the rendered template of the current route into the main layout (typically the index.html) file. Every time the current route changes, the included view changes with it according to the configuration of the $route service.