2017 © Pedro Peláez
 

yii2-extension yii2-angularjs

Yii2 widgets for angularjs

image

deesoft/yii2-angularjs

Yii2 widgets for angularjs

  • Monday, June 5, 2017
  • by mdmunir
  • Repository
  • 1 Watchers
  • 2 Stars
  • 72 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 3 % Grown

The README.md

yii2-angularjs

Installation

The preferred way to install this extension is through composer., (*1)

Either run, (*2)

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

or add, (*3)

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

to the require section of your composer.json file., (*4)

Usage

Module Widget

file index.php, (*5)

<div ng-app="angularYii">
    <?php Module::begin([
        'name' => 'angularYii', // module name, use for ng-app
        'controllers' => [
            'MainController' => [
                'sourceFile' => 'controllers/main-controller.js',
            ]
        ]
    ])?>
        <div ng-controller="MainController">
            <ul>
                <li ng-repeat="todo in todos">{{todo.name}}</li>
            </ul>
            <input ng-model="newValue"><button ng-click="addTodo()">Add</button>
        </div>
    <?php Module::end()?>
</div>

file controllers/main-controller.js, (*6)

function($scope){
    $scope.todos = [
        {name: 'Satu'},
        {name: 'Dua'},
        {name: 'Tiga'},
    ];

    $scope.addTodo = function(){
        $scope.todos.push({
            name:$scope.newValue,
        });
        $scope.newValue = '';
    }
}

NgRoute widget

NgRoute widget is special widget of Module. It has property routes, (*7)

file index.php, (*8)

<div ng-app="ngrouteYii">
    <?= NgRoute::widget([
        'name' => 'ngrouteYii',
        'routes' => [
            '/' => [
                'templateFile' => 'templates/main.php',
                'controllerFile' => 'controllers/main.js',
            ],
            '/view/:id' => [
                'templateFile' => 'templates/view.php',
                'controllerFile' => 'controllers/view.js',
            ],
            '/edit/:id' => [
                'templateFile' => 'templates/edit.php',
                'controllerFile' => 'controllers/edit.js',
            ],
            '*' => [ // otherwise
                'templateFile' => 'templates/not-found.php',
            ],
        ]
    ])?>
</div>

The Versions

05/06 2017

dev-master

9999999-dev

Yii2 widgets for angularjs

  Sources   Download

BSD-3-Clause

The Requires

 

by Misbahul Munir

yii2 angularjs widget