What is MAC address MAC(Media Access Control) address of a device is a unique identity assigned to it. It is used to identify a computer over a network. Similar to IP address, MAC address of a device is also unique. A MAC address is assigned during the manufacture process of hardware and remains constant throughout its life. It is also referred to as device address or physical address. MAC address is only assigned to Network Interface Controllers. These are hardware devices that connect to a network. Since these devices connect a computer to a network, they act as an interface between the two, hence calledRead More →

Scenario Suppose you have an empty table on an HTML page which has heading tags but its body is empty such as that given below. <table>    <thead>       <tr>          <th>S. No.</th>          <th>Name</th>          <th>ID</th>       </tr>    </thead>    <tbody>   <!– empty body –>    </tbody> </table> Content of the table’s body will be fetched from the server as HTML and will be set dynamically. Or let it be any random HTML which you want to fetch from the server and set it inside another element on HTMLRead More →

What are Pipes? Pipes are a way to transform or modify the data that is shown to the user. Typically, pipes perform utility functions by using a simple syntax which would otherwise require some coding. Example, suppose you want to show the name of an employee or some object in upper case, no matter in which case you are getting it from the backend source or you want to format a large number properly with commas according to its length(such as 1,23,000). Using pipes, this can be easily done. Syntax Pipes are applied to the data to be transformed by using pipe symbol( | ) followed byRead More →

There are times when you need to style an element or add some class to it only on a certain condition and not always. Example, on a shopping site, there may be thousands of items. But while displaying the page to a user, some items are displayed with an icon besides them such as a star or a heart to indicate that this item was marked as favorite sometime back by this user. This can be easily achieved by adding a class dynamically on the condition that this item was flagged as favorite or not. In angular, this is called Class Binding. How to addRead More →

Parent-Child component: Meaning An angular application is made up of components and often components are nested inside one-another. Example, suppose you have a table of rows on a page. In this simple structure we can have 2 components: A table component which represents the entire table and a component which represents a single row of the table. If we have this kind of structure, then table will contain row component and thus table component will be the Parent component and row component will be the Child component. In simple words, when one component contains another component, then the components are said to be nested. WhenRead More →

What is a service A service in Angular is a special typescript class which contains methods and fields like a normal typescript class but its methods and fields can be shared by components. A service is annotated with @Injectable annotation and it is directly injected into the component which wants to use it. Why is service required A service is used to perform utility functions such as fetching data from the server, logging to the console, reading a json file etc. Example: Imagine a component wants to fetch data from the server and show it on the browser. Logic to fetch data can be writtenRead More →

Swapping strings Swapping two strings means interchanging their values with one another. Example, there are two string variables s1 and s2 with values s1 = “codippa.com” and s2 = “the website”, Swapping the two strings will make their value as s1 = “the website” and s2 = “codippa.com” Common Approach The most common approach of swapping two strings is to store the value of one of the strings into a temporary variable and then assigning the value of second string to first one. Finally, assigning the value of temporary variable back to the first string as shown below String s1 = “codippa.com”; String s2 =Read More →

Overview Converting a string to number is a much required feature in any programming language. Number in javascript can be inferred as an integer(such as 10, 99, 1111 etc.) or a decimal number(such as 5.67, 9.999 etc.), also called floating numbers. Scenario Suppose you have a json string coming from a web server to browser. This json string has a field named visitorCount and you want to increment 1 to this value every time the page loads. Now, if you straightaway get its value and add 1 to it, it will be appended to the value instead of adding 1 to it. Thus an initialRead More →