For years, I have designed functioning web applications using PHP and jQuery. With technology having moved on substantially this approach is inefficient, slow and prone to errors.
In getting started with Angular I would first like to understand if it is capable of effectively replacing where php echo would have been used in the past.
Imagine an HTML div. The text contained within that div comes from a database, is rendered in php and echo'd into place.
Now imagine that the content needs to change. The page would be reloaded with php rendering the new information.
Angular appears to allow that a variable is placed within the div. Something like:
<div>{{variable}}</div>
I would like to know if it is possible to use this method to update content on the fly. The idea would be that a new data object is loaded containing all the variables needed. Say, the language is changed and therefore, all the existing text should be updated to reflect the new language.
- Can angular do this?
- Is there a simple example that just shows something akin to the process above?
The PHP way
<?
if($_POST["spanish"){
include('spanish_variables.php');
}
else {
include('english_variables.php')
}
?>
<div class="content">
<h2><? echo $variable_1->heading; ?></h2>
<p><? echo $variable_1->content; ?></p>
</div>