dtt78245 2013-04-07 13:49
浏览 49
已采纳

使用Laravel和AngularJs [关闭]

First sorry about my english i will do my best to explain. I recently started a project what will use heavy javascript, specially lot of ajax calls and ajax manipulations.

For example lke

  • facebook style dropdown notification
  • lot of different ajax forms
  • like button
  • follow button
  • image manupulations and uploads

I made similar with jQuery back in time and jQuery is the only library i know yet. But i was eyeing with AngularJs studied a lot about it and i am likeing it.

I was searching for Laravel + AngularJs tutorial but did not find any useful information for my answer.

So when i use jQuery for example, and i would like to retrive data from an attribute, or sending a form, i have to give it a class or id, but angular uses controllers.

So my question is it okay to mix the controllers with the view?

Example

<?php echo  Form::open() ?>

    <?php echo  Form::label('password', 'Password') ?>
    <?php echo  Form::password('password', array('class' => 'span4')) ?>
    <span class="help-block">5-12 characters.</span>
    <?php echo  $errors->has('password') ? $errors->first('password', '<p class="validation-error">:message</p>') : ''?>

    <?php echo  Form::label('confirm_password', 'Confirm password') ?>
    <?php echo  Form::password('confirm_password', array('class' => 'span4')) ?>
    <?php echo  $errors->has('confirm_password') ? $errors->first('confirm_password', '<p class="validation-error">:message</p>') : ''?>

    <div ng-controller="PhotoCtrl">
        //on image change preform auto upload
    </div>

    <?php echo  Form::button('Sign up', array('class' => 'btn btn-block btn-success')) ?>

<?php echo  Form::close() ?>

So in the above code what i posted, you see the ng-controller, mixing the 2 this way is good or bad?

Thank you

  • 写回答

1条回答 默认 最新

  • douwen3836 2013-04-07 14:28
    关注

    and yes it's fine to use those together, but sometimes you might want to consider writing a directive instead of a full controller.

    Directives can be written to handle small bits of functionality, where controllers group a bunch of actions together.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配