yii2-angular

Angularjs extension for Yii2

  • 所有者: deesoft/yii2-angular
  • 平台:
  • 许可证: GNU General Public License v3.0
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

yii2-angular

Yii2 angular extension

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require deesoft/yii2-angular "~1.0"

or add

"deesoft/yii2-angular": "~1.0"

to the require section of your composer.json file.

Usage

In view file

<?php
use dee\angular\NgView;

/* @var $this yii\web\View */
?>

<?= NgView::widget([
    'name' => 'myapp', // default dApp
    'routes'=>[
        '/'=>[
            'view' => 'index',
            'js' => 'index.js',
        ],
        '/view/:id'=>[
            'view'=>'view', 
            'js'=>'view.js',
            'injection'=>['$location', '$routeParams'], // $scope and $injector are always be added              
        ],
        '/edit/:id'=>[
            'view'=>'edit',
        ],
        '/create'=>[
            'view'=>'create',
        ],
    ]
])?>

Then index.php

<?php

use dee\angular\NgView;

/* @var $this yii\web\View */
/* @var $widget NgView */
?>

<ul>
    <li ng-repeat="item in items">
        <a ng-href="/view/{{item.id}}">{{item.name}}</a>
    </li>
</ul>

index.js

Rest = $injector.get('Rest');

query = function(){
    Rest.query({},function(r){
        $scope.items = r;
    });
}

$scope.deleteItem = function (id) {
    Rest.remove({id:id},{},function(){
        query();
    });
}

Use GII to generate crud

Install deesoft/yii2-gii then add config

...
if (!YII_ENV_TEST) {
//     configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = 'yii\debug\Module';

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'generators' => [
            'angular' => ['class' => 'dee\gii\generators\angular\Generator'],
        ]
    ];
}

主要指标

概览
名称与所有者deesoft/yii2-angular
主编程语言PHP
编程语言PHP (语言数: 2)
平台
许可证GNU General Public License v3.0
所有者活动
创建于2015-04-16 09:40:54
推送于2015-11-22 22:24:47
最后一次提交2015-09-08 15:52:51
发布数5
最新版本名称1.3 (发布于 )
第一版名称1.0.0 (发布于 )
用户参与
星数45
关注者数12
派生数17
提交数46
已启用问题?
问题数5
打开的问题数5
拉请求数0
打开的拉请求数1
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?