Sunday, February 28, 2016

Web Design and Development Tricks Using PHP in Sri Lanka

The Web Design Process




When a business needs a new website or they want to replace their existing one, they usually pass the project into the hands of a recommended web design and development agency. A sensible move. After all, most companies don’t have the in house expertise to tackle such a complicated project and one where the final result is critical in attracting new leads and generating product sales.
The creation of every website follows a clear web design process. A client who understands the basics of this process will appreciate what happens at each stage, will be clear about when the process can easily change direction and can communicate more knowledgeably with the web agency. Also, the more they know, the more the information provided by the web design team in their updates will make sense and prove more useful.
As such, we’ve created an infographic to display our vision of the web design process. It covers each step from the project brief and understanding the client’s needs to launching the final version and providing maintenance. Read on if you want to understand more about the process, if you want a stress-free relationship with your designers and developers and if you want to achieve a website that matches your needs and expectations.

Why does web development take so long?

A new website won’t happen overnight. When a web development company estimates the timeline to create a new website, some clients may be incredulous.
“I just want a few pretty looking pages with nice photos, and some internal clicks here and there. Oh and a ‘Sign Up for our Newsletter’ button, and the ‘Contact Us form’. But they’re easy to do, aren’t they? Surely that won’t take more than a week. Oh – did I mention the custom shopping cart and online payment system I need?”
If you’re hoping to get a new all-singing, all-dancing website, here’s why it may easily take 3 months before your customers will get to see it:

Step 1: Brief

brief-1brief-2brief-3brief-4brief-5brief-6brief-7brief-8
From the web design agency’s point of view, the brief is typically their first contact with the project or even with the client itself. It is also usually the most important step for both parties since everything discussed here will influence the end result. This is why the client must make sure to provide the clearest and most detailed brief possible.
The purpose of the brief is to convey an accurate project definition to the web agency. The client needs to explain their business, their target audience and the goals of the website – is it to wow a young visitor with exciting imagery and modern videos? Or is its function to allow no-nonsense online shopping for an average parent?
With the help of the agency, they need to define technical specifications – should the website be optimized for a certain resolution or browser? What kind of mobile version do they need? Would responsive design suffice?
Also during the brief, the client can present the content and resources that will be available to the agency during the rest of the process. Resources can include fonts, images, while content can include anything from product descriptions to articles, videos and so on.
Based on all this information, the web company can come to a conclusion regarding the project timeline, including any milestones and deadlines, and the estimated budget required to implement all the client’s needs.
We emphasize again that this is a critical step as it forms the foundation on which all the subsequent design and development work is based on. A poor or incomplete brief can lead to an unsatisfactory result, which will in turn lead to further web design costs and delays.

Step 2: Planning

planning-1planning-2planning-3planning-4planning-5planning-6
Armed with the information in the brief, the web development company can move on to the planning phase of the project.
During this step, through research and brainstorming sessions, the team will outline the first ideas and concepts for the website that would fit the client’s specifications.
An important part of this is usually the information architecture, which basically defines how the content will be structured throughout the website and how a visitor will access it. This also depends a lot on the brief data – does the client favor the infinite scroll (think Pinterest) or a web design with minimal content below the fold? The agency needs to find the way to smoothly move the visitor through the website to take the desired action – the so-called funnel approach.
Once a hierarchy of page organization is created, the layout of content on each page must be given consideration. Together with mapping out the location and operation of any functionalities – such as the online booking form and the online payment system – will ensure a proper usability for the site’s users.
The web development company must take responsibility for clearly explaining the logic behind the proposed navigation and layout to the client. On the other hand, the client must take responsibility for reviewing the proposed concepts carefully. If communications are weak at this point, the whole web development process will set off down the wrong path. If alterations are required, they can be easily made at this stage, but if they are required further down the line, far more time will be required and costs will increase.
With everything completed in this step, the first wireframes and mock-ups can be created which will further aid the design and development process.

Step 3: Design

design-1design-2design-3design-4design-5design-6design-7design-8design-9
This is the step where the website starts to take shape. The web designer will now have all the data needed to start working on the actual look of this project.
Among the first design tasks is choosing a proper color scheme. The color palette is all important because it sends an immediate message to the website visitor – vivid multicolored designs work well for kids’ organizations but financial institutions should opt for more subtle colors if they wish to instill trust in their audience.
The combination of logo and color scheme forms the basis of the company’s visual identity and influence how the visitors perceive the brand. Also, whether images appear in headers, sliders or as backgrounds, the best web designs use carefully chosen artwork imagery to help reinforce the company’s main messages.
Visual elements such as buttons, information boxes and menu boxes need to be designed to complement the tone of voice of the website – from formal, sharp edged boxes with traditional fonts best suited to the mature audience, to urban-style distressed boxes containing funky fonts to appeal to teens.
An increasing popular feature in web designs is the presence of videos and other rich media – the simplest way for a visitor to learn more about the company or its products and services without having to read reams of text. Rich media can also refer to animations, dynamic color-swatches, 3D spin models for products and many other visuals.
Throughout this process, the designer must ensure that the layout offers the best user experience so that the pages are not only easy on the eye but allow the visitor to quickly find what they need. This also extends to cross-device compatibility such as their template proposals can be adapted to suit a variety of devices from smart phones to desk tops.
Finally, a variety of prototype template variations fulfilling the criteria above must be prepared and analyzed together with the client to define the best option to move forward with.

Step 4: Development

development-1development-2development-3development-4development-5development-6development-7development-8
This is where we go behind the scenes to provide the actual website “feel”. The web development company now has to develop a website to meet all the requirements identified in the planning phase.
One of the main concerns of the development team is to ensure the website will be built to comply with all relevant accessibility and web standards such as the standards for HTML, CSS, XML and XSL. In Ontario it is also essential that all websites comply with AODA (Accessibility for Ontarians with Disabilities Act) which allows a website to be accessible by everyone.
The basis for developing the website is choosing the right framework. Frameworks are similar to pre-built templates that are used to create customized websites by writing additional code to get the final look and functionality. They are available in a variety of computer languages including PHP and JavaScript.
The alternative is to use a Content Management System (CMS) which is best when little customization is required. A CMS is a more advanced type of framework that offers a user interface. Examples include WordPress, which great for presentation websites, and PrestaShop or Magento for e-commerce businesses.
Whichever the choice, the developer will then focus on configuring the database. This forms the backbone of the website and it is built in line with the content and structure requirements.
The next step is to ensure the website functions properly – making sure all the buttons, sliders, filters, shopping carts etc. work and enable the visitor to move between pages and make online purchases. Following that, the client’s content will then be integrated into the website. This covers services information, category and product titles, descriptions and features, articles, videos and other types of content.
The development team will also constantly keep in mind the site’s performance. Depending on the number of features and their complexity, they can sometimes lead to a negative impact on speed and performance, and thus on potential leads or sales, which has to be mitigated.
Another important factor the development process is security. The website’s private data such as passwords, user information and private content must be made secure. This is done by ensuring the underlying code doesn’t allow any vulnerabilities or weaknesses such as XSS.
One of the final tasks for the developers is to add certain markup to the website’s pages. This usually doesn’t affect the user directly, but it is important for search engine optimization (SEO), such as using schema.org structured data, or for Social Media purposes, such as Facebook link share description and image tags.

Step 5: Launch

launch-1launch-2launch-3launch-4launch-5launch-6
The website has entered its final stages of testing, which basically means it’s almost ready to go live. Final tests usually focus on functionality, performance and security, as the web company gets ready to deliver the final product.
Once this has been done, the agency will transfer the project on to the client’s live server, where the website will be accessed by using the client’s domain name.
The launch phase is also where the client has a very important job – to help the web design company in the quality assurance testing of the website and to see what kind of user experience it offers. Often clients ask their staff to use the website and see if they find missing or incorrect content, broken links (links which head nowhere) and to check that online forms end up in the right email inbox.
Once the website is live, the client will usually provide the necessary code snippets used to integrate their web analytics services, such as Google Analytics or Webmaster Tools. In most cases this can be only done on the live server in order to associate the services with the domain and make the necessary check-ups.
With everything up and running, the web design company will provide the client with all the deliverables agreed at the beginning of the project. This usually refers to source code files for the website, the logo and other materials used in the planning, design and development stages.
Depending on the complexity of the project, the client will also receive training and documentation for properly using certain features of the site, such as an admin panel, customer management, and so forth.

Step 6: Maintenance

maintenance-1maintenance-2maintenance-3maintenance-4maintenance-5
The last step of the web design process is not one familiar to everyone. Unfortunately, a lot of clients believe that launching the website should end the collaboration with their web agency. The truth is, if you are truly invested in your online presence, then the web design process is never over.
So what happens in the maintenance phase? First and foremost, the web agency will provide support and troubleshoot any issue that you or any of your users encounter during their visits in order to maintain a happy audience.
The technical support also extends to periodic performance and security tests, updates or add-on installations, in the case of CMSes.
Second, while the website is indeed live and perhaps it even exceeded all your expectations, that doesn’t mean there’s no more room for optimizations. This is even more true as time passes and new trends emerge. The agency will usually use A/B testing to determine what changes best influence metrics such as click-through rates and conversions in order to maximize your website’s value.
And who can implement the resulting modifications or any other updates, whether they are related to design, functionality or just content, other than the team that put your site together in the first place? Using a different agency to modify your website most frequently results in higher costs and longer implementation times, even for very small changes.

Conclusion

After reading this article, if any client remains incredulous as to why web design and development is no overnight job, we will eat our hats!
It is clear that the numerous steps in the web design process all take time when done properly, though strong client-agency communication often helps to reduce it.
Hopefully this short overview will enable you to better understand the process. And armed with this information, not only will they understand the web design process, but they will be better equipped to communicate with and to assist the design and development team to create a website that both parties are truly proud of.






Infographic is a great way to turn the most boring data into the most comforting graphic, which is much easier for reader to digest. As web designers have to deal with pixels and code almost everyday, it would be overwhelming to look at more data and references which are filled with hypnotic words and numbers.

We understand how your eyes feel when they are suffering from sleep induction, and this leads us to compile 43 informative infographics that are relevant to web designers. While some of them are data like current state of the internet or social media, others contain useful knowledge which can also be used as a great reference sheet. So come take a glimpse, enjoy them and grab them! Digesting data and knowledge has never been so fun with infographics!


As the scientific community recognizes four new elements on the scientific periodic table, it seemed fitting for revenue-focused B2B marketers to join the club with our own chart. The Periodic Table of Marketing Attribution displays the key components necessary for a fully functional, data-driven attribution strategy.



While chemists in the scientific community anxiously await the final completion of the seventh row on the periodic chart, data scientists and revenue-focused marketers can show off their exclusive periodic table of 63 elements — signed, sealed, and delivered to you personally by your resident attribution experts.
The following infographic takes each section of elements and explains how they  apply to the process of B2B marketing attribution tactics.
image: http://cdn.business2community.com/wp-content/uploads/2016/01/Periodic-Table-Attribution-Infographic-545.png.png
Periodic-Table-Attribution-Infographic-545.png
(click to view larger)

SECTION #1: ATTRIBUTION MODELING

Attribution is the process of attributing revenue to specific marketing activities that contributed to the conversion of those customers. It can track keywords, campaigns, content, display ads, events (and more) and follow a customer through their interactions with all of those marketing touches. After they become a customer, an attribution model will assign revenue credit to those touches in a specific manner, depending on the model.
Single-touch models only assign credit to one source. Multi-touch models assign revenue credit to multiple touchpoints along the marketing funnel. And, full-path B2B marketing attribution models assign credit to all influential touchpoints from the beginning to the end of a customer’s journey.

SECTION #2: MARKETING CHANNELS

The marketing channels included in the periodic table are those that can specifically be tracked through a B2B marketing attribution program —
  • Website
  • Direct traffic
  • Blog
  • Offer download
  • Syndication
  • Social Media
  • Twitter
  • Linkedin
  • Facebook
  • Organic Search
  • AdWords
  • Google display network
  • Bing Ads
  • Retargeting
  • Email
  • Newsletter
  • Outbound calling
  • Live chat
  • Partners
  • Referral traffic
All of these sources of leads, opportunities, and customers can be specifically tracked directly to revenue in order to see which channels (or which activities within the channels) are generating the most revenue. B2B marketing attribution strategy is gearing up to be one of the most influential components of a martech stack — because it measures the effectiveness of the entire strategy on a granular level.

SECTION #3: MARKETING ACTIVITIES

The activity elements listed in this portion of the periodic table refer to marketing initiatives that can directly create touchpoints within an attribution program. Each one can serve as a conversion point within the marketing and sales funnel, and each one can be assigned revenue credit in order to gauge how well the respective initiative contributes to the bottom line. From email nurturing and online content, to events and webinars, B2B marketing attribution measures all types of marketing activities, whether they’re online or offline.
Recommended for YouWebcast: Agile Marketing: Pour Gas on Your Growth Fire

SECTION #4: CHANNEL MAPPING

How does an attribution program actually map each touchpoint to its respective channel? How does a conversion point get assigned revenue credit? These elements display the different components used to map touchpoints to their channels and organize them in a way that can be easily sorted through and reported on by a B2B marketer.
The most common ways this is done is through API integrations, cookies, and UTM parameters, which collectively work together to gather tracking data and push that information into the CRM. After that occurs, an attribution program will take it the rest of the way and sort, organize, and process that data into neat dashboards and spiffy reports that allow marketers to easily understand the effectiveness of their marketing.

SECTION #5: ATTRIBUTION METRICS

These elements are a short list of the types of advanced and specialized attribution metrics that a B2B attribution software program can generate. These types of metrics aren’t available through any other type of martech program, because they rely on highly granular and incredibly accurate data. Metrics such as leads by websource, opportunities by channel, and revenue by keyword will help marketers know which channels are making them the most money and how to optimize in order to generate a greater level of ROI.

Read more at http://www.business2community.com/infographics/periodic-table-elements-b2b-marketing-attribution-infographic-01420296#uc6p4q8WqrjQ5rei.99


MSc BIT BSc HND Edxcel PHP Web Application Projects Assignments Guidance.
London A/L O/L ICT Class
Individual / Group / Online classes in English / Sinhala / Tamil. Sample PHP Projects/Assignments Exam Papers, Tutorials, Notes and Answers will be provided. Call +94 777 33 7279 | eMail itclasssl@gmail.com | Skype ITClassSL

Friday, January 29, 2016

IT6105 - BIT UCSC FINAL YEAR PROJECT 2017 Guidance Help Supervisor/Advisor In Sinhala English Tamil IT ICT Online Classes


IT6105 - Student Hand Book 2016


IT6105 - FINAL YEAR PROJECT 2016

 Please use the following documents for the Final Year Project  (IT6105)
 Mon, 01/04/2016 - 07:40
Deadline (on or before)
Description
 January, 
Beginning of the academic year
14th January, 
Registration for project & project evaluation  (Pay Rs.6,000 at the EDC on or before 14th of January, 2016)
15th February, 2016

Submission of the signed Supervisor Agreement Form and Client Agreement Form to the EDC or VLE
29th March 2016
12th April 2016
26th April 2016
03rd May 2016
18th May 2016
28th June2016
12th July 2016
26th July 2016
09th August 2016
23rd August 2016




Submission of 10 Progress Reports through the VLE
14h June 2016
Interim Report submission through the VLE
30th September 2016
October
Publication of project evaluation schedule on the BIT web site
October /November
Project evaluation at the UCSC (Each candidate should bring one spiral bound copy of the project dissertation, CD with a copy of project software and a computer with all software installed and data entered.)
November/ December
Feedback for dissertation corrections (through the BIT web site)
December
Approval for dissertation corrections (payment of Rs. 1000 for resubmission, if applicable)
January
Submission of Final Dissertation (One hard bound copy of the dissertation prepared according to guidelines described under Section 3.5) and one CD with a printout of its directory contents to the UCSC (see section 3.6)

PROJECT DISSERTATION EVALUATION SCHEDULE 3 2017
Instructions
In examination phase (30 – 45 minutes) you are not allowed to use a mobile phone or to leave the examination hall.
Please note that must bring your BIT ID, original client certificate and original declaration page of the report. Note that we evaluate your dissertation already submitted. Therefore you should not bring a additional copy of your dissertation.
Read the  Project Guidelines document (available in the BIT website) before coming to the defense.
Project dissertation evaluations will be conducted at the UCSC , 35, Reid Avenue, Colombo 7 .
The dissertation evaluation of the students listed below will be held on 7th January 2017.
Dissertation Evaluation Schedule Link
This project schedule is given in Table 4.1 of the Project Guidelines.  Refer the VLE for details and forms. All submissions have to either reach the EDC (agreement forms only) or uploaded to VLE on or before the specified deadlines.No postal or e-mail submissions will be entertained. Late submissions will not be accepted.
YouTube https://www.youtube.com/channel/UCJojbxGV0sfU1QPWhRxx4-A
LinkedIn https://www.linkedin.com/in/ict-bit-tuition-class-software-development-colombo/
WordPress https://computerclassinsrilanka.wordpress.com
quora https://www.quora.com/profile/BIT-UCSC-UoM-Final-Year-Student-Project-Guide
Newsletter https://sites.google.com/view/the-leaning-tree/newsletter
Wix https://itclasssl.wixsite.com/icttraining
Web https://itclass-bit-ucsc-uom-php-final-project.business.site/
mystrikingly https://bit-ucsc-uom-final-year-project-ideas-help-guide-php-class.mystrikingly.com/
https://elakiri.com/threads/bit-ucsc-uom-php-mysql-project-guidance-and-individual-classes-in-colombo.1627048/
ucsc bit registration 2023 bit (ucsc syllabus) bit colombo university fees bit results bit vle bit course fee bit exam time table 2023 bit moratuwa

Thursday, December 24, 2015

Angularjs tutorial step by step for beginners with examples

What is AngularJS?

AngularJS is a JavaScript MVC framework developed by Google that lets you build well structured, easily testable, and maintainable front-end applications.

And Why Should I Use It?

If you haven’t tried AngularJS yet, you’re missing out. The framework consists of a tightly integrated toolset that will help you build well structured, rich client-side applications in a modular fashion—with less code and more flexibility.
AngularJS extends HTML by providing directives that add functionality to your markup and allow you to create powerful dynamic templates. You can also create your own directives, crafting reusable components that fill your needs and abstracting away all the DOM manipulation logic.
It also implements two-way data binding, connecting your HTML (views) to your JavaScript objects (models) seamlessly. In simple terms, this means that any update on your model will be immediately reflected in your view without the need for any DOM manipulation or event handling (e.g., with jQuery).
Angular provides services on top of XHR that dramatically simplify your code and allow you to abstract API calls into reusable services. With that, you can move your model and business logic to the front-end and build back-end agnostic web apps.
Finally, I love Angular because of its flexibility regarding server communication. Like most JavaScript MVC frameworks, it lets you work with any server-side technology as long as it can serve your app through a RESTful web API. But Angular also provides services on top of XHR that dramatically simplify your code and allow you to abstract API calls into reusable services. As a result, you can move your model and business logic to the front-end and build back-end agnostic web apps. In this post, we’ll do just that, one step at a time.

So, Where Do I Begin?

First, let’s decide the nature of the app we want to build. In this guide, we’d prefer not to spend too much time on the back-end, so we’ll write something based on data that’s easily attainable on the Internet—like a sports feed app!
Since I happen to be a huge fan of motor racing and Formula 1, I’ll use an autosport API service to act as our back-end. Luckily, the guys atErgast are kind enough to provide a free motorsport API that will be perfect for us.
For a sneak peak at what we’re going to build, take a look at the live demo. To prettify the demo and show off some Angular templating, I applied a Bootstrap theme from WrapBootstrap, but seeing as this article isn’t about CSS, I’ll just abstract it away from the examples and leave it out.

Getting Started Tutorial

Let’s kickstart our example app with some boilerplate. I recommend theangular-seed project as it not only provides you with a great skeleton for bootstrapping, but also sets the ground for unit testing with Karma andJasmine (we won’t be doing any testing in this demo, so we’ll just leave that stuff aside for now; see Part 2 of this tutorial for more info on setting up your project for unit and end-to-end testing).
EDIT (May 2014): Since I wrote this tutorial, the angular-seed project has gone through some heavy changes (including the additon of Bower as package manager). If you have any doubts about how to deploy the project, take a quick look at the first section of their reference guide. InPart 2 of ths tutorial, Bower, among other tools, is covered in greater detail.
OK, now that we’ve cloned the repository and installed the dependencies, our app’s skeleton will look like this:
angularjs tutorial - start with the skeleton
Now we can start coding. As we’re trying to build a sports feed for a racing championship, let’s begin with the most relevant view: the championship table.
the championship table
Given that we already have a drivers list defined within our scope (hang with me – we’ll get there), and ignoring any CSS (for readability), our HTML might look like:
<body ng-app="F1FeederApp" ng-controller="driversController">
  <table>
    <thead>
      <tr><th colspan="4">Drivers Championship Standings</th></tr>
    </thead>
    <tbody>
      <tr ng-repeat="driver in driversList">
        <td>{{$index + 1}}</td>
        <td>
          <img src="img/flags/{{driver.Driver.nationality}}.png" />
          {{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}}
        </td>
        <td>{{driver.Constructors[0].name}}</td>
        <td>{{driver.points}}</td>
      </tr>
    </tbody>
  </table>
</body>
The first thing you’ll notice in this template is the use of expressions (“{{“ and “}}”) to return variable values. In AngularJS, expressions allow you to execute some computation in order to return a desired value. Some valid expressions would be:
  • {{ 1 + 1 }}
  • {{ 946757880 | date }}
  • {{ user.name }}
Effectively, expressions are JavaScript-like snippets. But despite being very powerful, you shouldn’t use expressions to implement any higher-level logic. For that, we use directives.

Understanding Basic Directives

The second thing you’ll notice is the presence of ng-attributes, which you wouldn’t see in typical markup. Those are directives.
At a high level, directives are markers (such as attributes, tags, and class names) that tell AngularJS to attach a given behaviour to a DOM element (or transform it, replace it, etc.). Let’s take a look at the ones we’ve seen already:
  • The ng-app directive is responsible for bootstrapping your app defining its scope. In AngularJS, you can have multiple apps within the same page, so this directive defines where each distinct app starts and ends.
  • The ng-controller directive defines which controller will be in charge of your view. In this case, we denote the driversController, which will provide our list of drivers (driversList).
  • The ng-repeat directive is one of the most commonly used and serves to define your template scope when looping through collections. In the example above, it replicates a line in the table for each driver in driversList.

Adding Controllers

Of course, there’s no use for our view without a controller. Let’s add driversController to our controllers.js:
angular.module('F1FeederApp.controllers', []).
controller('driversController', function($scope) {
    $scope.driversList = [
      {
          Driver: {
              givenName: 'Sebastian',
              familyName: 'Vettel'
          },
          points: 322,
          nationality: "German",
          Constructors: [
              {name: "Red Bull"}
          ]
      },
      {
          Driver: {
          givenName: 'Fernando',
              familyName: 'Alonso'
          },
          points: 207,
          nationality: "Spanish",
          Constructors: [
              {name: "Ferrari"}
          ]
      }
    ];
});
You may have noticed the $scope variable we’re passing as a parameter to the controller. The $scope variable is supposed to link your controller and views. In particular, it holds all the data that will be used within your template. Anything you add to it (like the driversListin the above example) will be directly accessible in your views. For now, let’s just work with a dummy (static) data array, which we will replace later with our API service.
Now, add this to app.js:
angular.module('F1FeederApp', [
  'F1FeederApp.controllers'
]);
With this line of code, we actually initialize our app and register the modules on which it depends. We’ll come back to that file (app.js) later on.
Now, let’s put everything together in index.html:
<!DOCTYPE html>
<html>
<head>
  <title>F-1 Feeder</title>
</head>

<body ng-app="F1FeederApp" ng-controller="driversController">
  <table>
    <thead>
      <tr><th colspan="4">Drivers Championship Standings</th></tr>
    </thead>
    <tbody>
      <tr ng-repeat="driver in driversList">
        <td>{{$index + 1}}</td>
        <td>
          <img src="img/flags/{{driver.Driver.nationality}}.png" />
          {{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}}
        </td>
        <td>{{driver.Constructors[0].name}}</td>
        <td>{{driver.points}}</td>
      </tr>
    </tbody>
  </table>
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="js/app.js"></script>
  <script src="js/services.js"></script>
  <script src="js/controllers.js"></script>
</body>
</html>
Modulo minor mistakes, you can now boot up your app and check your (static) list of drivers.
Note: If you need help debugging your app and visualizing your models and scope within the browser, I recommend taking a look at the awesome Batarang plugin for Chrome.
Like what you're reading?
Get the latest updates first.
No spam. Just great engineering and design posts.

Loading Data From the Server

Since we already know how to display our controller’s data in our view, it’s time to actually fetch live data from a RESTful server.
To facilitate communication with HTTP servers, AngularJS provides the $http and $resource services. The former is but a layer on top ofXMLHttpRequest or JSONP, while the latter provides a higher level of abstraction. We’ll use $http.
To abstract our server API calls from the controller, let’s create our own custom service which will fetch our data and act as a wrapper around $http by adding this to our services.js:
angular.module('F1FeederApp.services', []).
  factory('ergastAPIservice', function($http) {

    var ergastAPI = {};

    ergastAPI.getDrivers = function() {
      return $http({
        method: 'JSONP', 
        url: 'http://ergast.com/api/f1/2013/driverStandings.json?callback=JSON_CALLBACK'
      });
    }

    return ergastAPI;
  });
With the first two lines, we create a new module (F1FeederApp.services) and register a service within that module (ergastAPIservice). Notice that we pass $http as a parameter to that service. This tells Angular’sdependency injection engine that our new service requires (or depends on) the $http service.
In a similar fashion, we need to tell Angular to include our new module into our app. Let’s register it with app.js, replacing our existing code with:
angular.module('F1FeederApp', [
  'F1FeederApp.controllers',
  'F1FeederApp.services'
]);
Now, all we need to do is tweak our controller.js a bit, include ergastAPIservice as a dependency, and we’ll be good to go:
angular.module('F1FeederApp.controllers', []).
  controller('driversController', function($scope, ergastAPIservice) {
    $scope.nameFilter = null;
    $scope.driversList = [];

    ergastAPIservice.getDrivers().success(function (response) {
        //Dig into the responde to get the relevant data
        $scope.driversList = response.MRData.StandingsTable.StandingsLists[0].DriverStandings;
    });
  });
Now reload the app and check out the result. Notice that we didn’t make any changes to our template, but we added a nameFilter variable to our scope. Let’s put that variable to use.

Filters

Great! We have a functional controller. But it only shows a list of drivers. Let’s add some functionality by implementing a simple text search input which will filter our list. Let’s add the following line to our index.html, right below the <body> tag:
<input type="text" ng-model="nameFilter" placeholder="Search..."/>
We are now making use of the ng-model directive. This directive binds our text field to the $scope.nameFilter variable and makes sure that its value is always up-to-date with the input value. Now, let’s visit index.html one more time and make a small adjustment to the line that contains theng-repeat directive:
<tr ng-repeat="driver in driversList | filter: nameFilter">
This line tells ng-repeat that, before outputting the data, the driversList array must be filtered by the value stored in nameFilter.
At this point, two-way data binding kicks in: every time a value is input in the search field, Angular immediately ensures that the $scope.nameFilter that we associated with it is updated with the new value. Since the binding works both ways, the moment the nameFiltervalue is updated, the second directive associated to it (i.e., the ng-repeat) also gets the new value and the view is updated immediately.
Reload the app and check out the search bar.
app search bar
Notice that this filter will look for the keyword on all attributes of the model, including the ones we´re not using. Let’s say we only want to filter by Driver.givenName and Driver.familyName: First, we add to driversController, right below the $scope.driversList = []; line:
$scope.searchFilter = function (driver) {
    var keyword = new RegExp($scope.nameFilter, 'i');
    return !$scope.nameFilter || keyword.test(driver.Driver.givenName) || keyword.test(driver.Driver.familyName);
};
Now, back to index.html, we update the line that contains the ng-repeat directive:
<tr ng-repeat="driver in driversList | filter: searchFilter">
Reload the app one more time and now we have a search by name.

Routes

Our next goal is to create a driver details page which will let us click on each driver and see his/her career details.
First, let’s include the $routeProvider service (in app.js) which will help us deal with these varied application routes. Then, we’ll add two such routes: one for the championship table and another for the driver details. Here’s our new app.js:
angular.module('F1FeederApp', [
  'F1FeederApp.services',
  'F1FeederApp.controllers',
  'ngRoute'
]).
config(['$routeProvider', function($routeProvider) {
  $routeProvider.
 when("/drivers", {templateUrl: "partials/drivers.html", controller: "driversController"}).
 when("/drivers/:id", {templateUrl: "partials/driver.html", controller: "driverController"}).
 otherwise({redirectTo: '/drivers'});
}]);
With that change, navigating to http://domain/#/drivers will load the driversController and look for the partial view to render in partials/drivers.html. But wait! We don’t have any partial views yet, right? We’ll need to create those too.

Partial Views

AngularJS will allow you to bind your routes to specific controllers and views.
But first, we need to tell Angular where to render these partial views. For that, we’ll use the ng-view directive, modifying our index.html to mirror the following:
<!DOCTYPE html>
<html>
<head>
  <title>F-1 Feeder</title>
</head>

<body ng-app="F1FeederApp">
  <ng-view></ng-view>
  <script src="bower_components/angular/angular.js"></script>
  <script src="bower_components/angular-route/angular-route.js"></script>
  <script src="js/app.js"></script>
  <script src="js/services.js"></script>
  <script src="js/controllers.js"></script>
</body>
</html>
Now, whenever we navigate through our app routes, Angular will load the associated view and render it in place of the <ng-view> tag. All we need to do is create a file named partials/drivers.html and put our championship table HTML there. We’ll also use this chance to link the driver name to our driver details route:
<input type="text" ng-model="nameFilter" placeholder="Search..."/>
<table>
<thead>
  <tr><th colspan="4">Drivers Championship Standings</th></tr>
</thead>
<tbody>
  <tr ng-repeat="driver in driversList | filter: searchFilter">
    <td>{{$index + 1}}</td>
    <td>
      <img src="img/flags/{{driver.Driver.nationality}}.png" />
      <a href="#/drivers/{{driver.Driver.driverId}}">
    {{driver.Driver.givenName}}&nbsp;{{driver.Driver.familyName}}
   </a>
 </td>
    <td>{{driver.Constructors[0].name}}</td>
    <td>{{driver.points}}</td>
  </tr>
</tbody>
</table>
Finally, let’s decide what we want to show in the details page. How about a summary of all the relevant facts about the driver (e.g., birth, nationality) along with a table containing his/her recent results? To do that, we add to services.js:
angular.module('F1FeederApp.services', [])
  .factory('ergastAPIservice', function($http) {

    var ergastAPI = {};

    ergastAPI.getDrivers = function() {
      return $http({
        method: 'JSONP', 
        url: 'http://ergast.com/api/f1/2013/driverStandings.json?callback=JSON_CALLBACK'
      });
    }

    ergastAPI.getDriverDetails = function(id) {
      return $http({
        method: 'JSONP', 
        url: 'http://ergast.com/api/f1/2013/drivers/'+ id +'/driverStandings.json?callback=JSON_CALLBACK'
      });
    }

    ergastAPI.getDriverRaces = function(id) {
      return $http({
        method: 'JSONP', 
        url: 'http://ergast.com/api/f1/2013/drivers/'+ id +'/results.json?callback=JSON_CALLBACK'
      });
    }

    return ergastAPI;
  });
This time, we provide the driver’s ID to the service so that we retrieve the information relevant solely to a specific driver. Now, we modify controllers.js:
angular.module('F1FeederApp.controllers', []).

  /* Drivers controller */
  controller('driversController', function($scope, ergastAPIservice) {
    $scope.nameFilter = null;
    $scope.driversList = [];
    $scope.searchFilter = function (driver) {
        var re = new RegExp($scope.nameFilter, 'i');
        return !$scope.nameFilter || re.test(driver.Driver.givenName) || re.test(driver.Driver.familyName);
    };

    ergastAPIservice.getDrivers().success(function (response) {
        //Digging into the response to get the relevant data
        $scope.driversList = response.MRData.StandingsTable.StandingsLists[0].DriverStandings;
    });
  }).

  /* Driver controller */
  controller('driverController', function($scope, $routeParams, ergastAPIservice) {
    $scope.id = $routeParams.id;
    $scope.races = [];
    $scope.driver = null;

    ergastAPIservice.getDriverDetails($scope.id).success(function (response) {
        $scope.driver = response.MRData.StandingsTable.StandingsLists[0].DriverStandings[0]; 
    });

    ergastAPIservice.getDriverRaces($scope.id).success(function (response) {
        $scope.races = response.MRData.RaceTable.Races; 
    }); 
  });
The important thing to notice here is that we just injected the $routeParams service into the driver controller. This service will allow us to access our URL parameters (for the :id, in this case) using $routeParams.id.
Now that we have our data in the scope, we only need the remaining partial view. Let’s create a file named partials/driver.html and add:
<section id="main">
  <a href="./#/drivers"><- Back to drivers list</a>
  <nav id="secondary" class="main-nav">
    <div class="driver-picture">
      <div class="avatar">
        <img ng-show="driver" src="img/drivers/{{driver.Driver.driverId}}.png" />
        <img ng-show="driver" src="img/flags/{{driver.Driver.nationality}}.png" /><br/>
        {{driver.Driver.givenName}} {{driver.Driver.familyName}}
      </div>
    </div>
    <div class="driver-status">
      Country: {{driver.Driver.nationality}}   <br/>
      Team: {{driver.Constructors[0].name}}<br/>
      Birth: {{driver.Driver.dateOfBirth}}<br/>
      <a href="{{driver.Driver.url}}" target="_blank">Biography</a>
    </div>
  </nav>

  <div class="main-content">
    <table class="result-table">
      <thead>
        <tr><th colspan="5">Formula 1 2013 Results</th></tr>
      </thead>
      <tbody>
        <tr>
          <td>Round</td> <td>Grand Prix</td> <td>Team</td> <td>Grid</td> <td>Race</td>
        </tr>
        <tr ng-repeat="race in races">
          <td>{{race.round}}</td>
          <td><img  src="img/flags/{{race.Circuit.Location.country}}.png" />{{race.raceName}}</td>
          <td>{{race.Results[0].Constructor.name}}</td>
          <td>{{race.Results[0].grid}}</td>
          <td>{{race.Results[0].position}}</td>
        </tr>
      </tbody>
    </table>
  </div>

</section>
Notice that we’re now putting the ng-show directive to good use. This directive will only show the HTML element if the expression provided is true (i.e., neither false, nor null). In this case, the avatar will only show up once the driver object has been loaded into the scope by the controller.

Finishing Touches

Add in a bunch of CSS and render your page. You should end up with something like this:
page rendered with CSS
You’re now ready to fire up your app and make sure both routes are working as desired. You could also add a static menu to index.html to improve the user’s navigation capabilities. The possibilities are endless.

Grade 6 Civic 1.3 Self identity, Special individual, Focus your attentio...

Identity and Self-Recognition: Students are encouraged to understand and embrace their own identities. Good qualities and characteristics he...