dos8244 2019-03-23 16:04
浏览 46

为AngularJS刮刮PHP和jQuery Ajax - 初学者

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.

  1. Can angular do this?
  2. 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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 不是,这到底错哪儿了😭
    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私