JSFiddle - React, Tailwind, and code Playground

by whtevn

HTML

<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyDisplayCtrl">
    <select ng-options=""></select>
</div>

<div ng-controller="MyManageCtrl">
  <div ng-repeat="item in items">
     {{item.name}}
  </div>
  <input type="button" ng-click="addItem()" value="add item" />
</div>

JavaScript

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyManageCtrl($scope, ItemStore) {
    $scope.items = ItemStore.items;
    $scope.addItem = ItemStore.addItem;
}
MyManageCtrl.$inject = ['$scope', 'ItemStore']


function MyDisplayCtrl($scope, ItemStore) {
    $scope.items = ItemStore.items;

}
MyDisplayCtrl.$inject = ['$scope', 'ItemStore']

myApp.factory('ItemStore', function(){
    var items = [{name: ' first item '}];
    var addItem = function(){
        items.push({name: 'item '+items.length});
    };
    
    return({
    items: items,
    addItem: addItem});   
});