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?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?