├── .angular-cli.json
├── .editorconfig
├── .gitignore
├── LICENSE
├── README.md
├── demo.png
├── e2e
├── app.e2e-spec.ts
├── app.po.ts
└── tsconfig.e2e.json
├── karma.conf.js
├── package.json
├── protractor.conf.js
├── src
├── anglarjs.ts
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── app.routing.ts
│ ├── dashboard
│ │ ├── about
│ │ │ ├── about.component.css
│ │ │ ├── about.component.html
│ │ │ └── about.component.ts
│ │ ├── dashboard.component.css
│ │ ├── dashboard.component.html
│ │ ├── dashboard.component.spec.ts
│ │ ├── dashboard.component.ts
│ │ └── dashboard.module.ts
│ ├── home
│ │ ├── about
│ │ │ ├── about.component.css
│ │ │ ├── about.component.html
│ │ │ └── about.component.ts
│ │ ├── home.component.css
│ │ ├── home.component.html
│ │ ├── home.component.spec.ts
│ │ ├── home.component.ts
│ │ ├── home.module.ts
│ │ └── ng1
│ │ │ ├── grid.component.ts
│ │ │ └── grid.directive.ts
│ ├── ng1
│ │ ├── directive.ts
│ │ └── grid.component.ts
│ ├── route1
│ │ └── route1.component.ts
│ ├── route2
│ │ └── route2.component.ts
│ └── shared
│ │ ├── shared.component.css
│ │ ├── shared.component.html
│ │ ├── shared.component.spec.ts
│ │ ├── shared.component.ts
│ │ └── shared.module.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.app.json
├── tsconfig.spec.json
└── typings.d.ts
├── tsconfig.json
└── tslint.json
/.angular-cli.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "project": {
4 | "name": "grid2"
5 | },
6 | "apps": [
7 | {
8 | "root": "src",
9 | "outDir": "dist",
10 | "assets": [
11 | "assets",
12 | "favicon.ico"
13 | ],
14 | "index": "index.html",
15 | "main": "main.ts",
16 | "polyfills": "polyfills.ts",
17 | "test": "test.ts",
18 | "tsconfig": "tsconfig.app.json",
19 | "testTsconfig": "tsconfig.spec.json",
20 | "prefix": "app",
21 | "styles": [
22 | "styles.css",
23 | "../node_modules/angular-ui-grid/ui-grid.min.css"
24 | ],
25 | "scripts": [
26 | "../node_modules/angular/angular.min.js",
27 | "../node_modules/angular-ui-grid/ui-grid.min.js"
28 | ],
29 | "environmentSource": "environments/environment.ts",
30 | "environments": {
31 | "dev": "environments/environment.ts",
32 | "prod": "environments/environment.prod.ts"
33 | }
34 | }
35 | ],
36 | "e2e": {
37 | "protractor": {
38 | "config": "./protractor.conf.js"
39 | }
40 | },
41 | "lint": [
42 | {
43 | "project": "src/tsconfig.app.json"
44 | },
45 | {
46 | "project": "src/tsconfig.spec.json"
47 | },
48 | {
49 | "project": "e2e/tsconfig.e2e.json"
50 | }
51 | ],
52 | "test": {
53 | "karma": {
54 | "config": "./karma.conf.js"
55 | }
56 | },
57 | "defaults": {
58 | "styleExt": "css",
59 | "component": {}
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist
5 | /tmp
6 |
7 | # dependencies
8 | /node_modules
9 | /bower_components
10 |
11 | # IDEs and editors
12 | /.idea
13 | /.vscode
14 | .project
15 | .classpath
16 | .c9/
17 | *.launch
18 | .settings/
19 |
20 | # misc
21 | /.sass-cache
22 | /connect.lock
23 | /coverage/*
24 | /libpeerconnection.log
25 | npm-debug.log
26 | testem.log
27 | /typings
28 |
29 | # e2e
30 | /e2e/*.js
31 | /e2e/*.map
32 |
33 | #System Files
34 | .DS_Store
35 | Thumbs.db
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Vlado Tesanovic
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # UI Grid and Angular 2
2 |
3 | Demo: ui-grid2.surge.sh
4 |
5 |
6 |
--------------------------------------------------------------------------------
/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/demo.png
--------------------------------------------------------------------------------
/e2e/app.e2e-spec.ts:
--------------------------------------------------------------------------------
1 | import { A2ttPage } from './app.po';
2 |
3 | describe('a2tt App', () => {
4 | let page: A2ttPage;
5 |
6 | beforeEach(() => {
7 | page = new A2ttPage();
8 | });
9 |
10 | it('should display message saying app works', () => {
11 | page.navigateTo();
12 | expect(page.getParagraphText()).toEqual('app works!');
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/e2e/app.po.ts:
--------------------------------------------------------------------------------
1 | import { browser, element, by } from 'protractor';
2 |
3 | export class A2ttPage {
4 | navigateTo() {
5 | return browser.get('/');
6 | }
7 |
8 | getParagraphText() {
9 | return element(by.css('app-root h1')).getText();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/e2e/tsconfig.e2e.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "sourceMap": true,
4 | "declaration": false,
5 | "moduleResolution": "node",
6 | "emitDecoratorMetadata": true,
7 | "experimentalDecorators": true,
8 | "lib": [
9 | "es2016"
10 | ],
11 | "outDir": "../dist/out-tsc-e2e",
12 | "module": "commonjs",
13 | "target": "es6",
14 | "types":[
15 | "jasmine",
16 | "node"
17 | ]
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | // Karma configuration file, see link for more information
2 | // https://karma-runner.github.io/0.13/config/configuration-file.html
3 |
4 | module.exports = function (config) {
5 | config.set({
6 | basePath: '',
7 | frameworks: ['jasmine', '@angular/cli'],
8 | plugins: [
9 | require('karma-jasmine'),
10 | require('karma-chrome-launcher'),
11 | require('karma-jasmine-html-reporter'),
12 | require('karma-coverage-istanbul-reporter'),
13 | require('@angular/cli/plugins/karma')
14 | ],
15 | client:{
16 | clearContext: false // leave Jasmine Spec Runner output visible in browser
17 | },
18 | files: [
19 | { pattern: './src/test.ts', watched: false }
20 | ],
21 | preprocessors: {
22 | './src/test.ts': ['@angular/cli']
23 | },
24 | mime: {
25 | 'text/x-typescript': ['ts','tsx']
26 | },
27 | coverageIstanbulReporter: {
28 | reports: [ 'html', 'lcovonly' ],
29 | fixWebpackSourcePaths: true
30 | },
31 | angularCli: {
32 | environment: 'dev'
33 | },
34 | reporters: config.angularCli && config.angularCli.codeCoverage
35 | ? ['progress', 'coverage-istanbul']
36 | : ['progress', 'kjhtml'],
37 | port: 9876,
38 | colors: true,
39 | logLevel: config.LOG_INFO,
40 | autoWatch: true,
41 | browsers: ['Chrome'],
42 | singleRun: false
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "grid2",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "start": "ng serve --port 3388 --aot=false",
7 | "lint": "ng lint",
8 | "test": "ng test",
9 | "e2e": "ng e2e",
10 | "build": "ng build --prod --sm=false --aot=true",
11 | "run": "cd dist && python -m SimpleHTTPServer 8001"
12 | },
13 | "private": true,
14 | "dependencies": {
15 | "@angular/common": "^4.1.0",
16 | "@angular/compiler": "^4.1.0",
17 | "@angular/core": "^4.1.0",
18 | "@angular/forms": "^4.1.0",
19 | "@angular/http": "^4.1.0",
20 | "@angular/cli": "^1.0.1",
21 | "@angular/platform-browser": "^4.1.0",
22 | "@angular/platform-browser-dynamic": "^4.1.0",
23 | "@angular/router": "^4.1.0",
24 | "@angular/upgrade": "^4.1.0",
25 | "core-js": "^2.4.1",
26 | "rxjs": "^5.1.0",
27 | "zone.js": "^0.8.9",
28 | "angular": "1.5.9",
29 | "angular-ui-grid": "^4.0.4",
30 | "ts-helpers": "^1.1.1"
31 | },
32 | "devDependencies": {
33 | "@types/angular": "^1.5.20",
34 | "@angular/compiler-cli": "^4.1.0",
35 | "@types/jasmine": "2.5.38",
36 | "@types/node": "~6.0.60",
37 | "codelyzer": "~3.0.0",
38 | "jasmine-core": "~2.5.2",
39 | "jasmine-spec-reporter": "~3.2.0",
40 | "karma": "~1.4.1",
41 | "karma-chrome-launcher": "~2.0.0",
42 | "karma-cli": "~1.0.1",
43 | "karma-jasmine": "~1.1.0",
44 | "karma-jasmine-html-reporter": "^0.2.2",
45 | "karma-coverage-istanbul-reporter": "^0.2.0",
46 | "protractor": "~5.1.0",
47 | "ts-node": "~3.0.2",
48 | "tslint": "~5.1.0",
49 | "typescript": "^2.2.2"
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/protractor.conf.js:
--------------------------------------------------------------------------------
1 | // Protractor configuration file, see link for more information
2 | // https://github.com/angular/protractor/blob/master/lib/config.ts
3 |
4 | const { SpecReporter } = require('jasmine-spec-reporter');
5 |
6 | exports.config = {
7 | allScriptsTimeout: 11000,
8 | specs: [
9 | './e2e/**/*.e2e-spec.ts'
10 | ],
11 | capabilities: {
12 | 'browserName': 'chrome'
13 | },
14 | directConnect: true,
15 | baseUrl: 'http://localhost:4200/',
16 | framework: 'jasmine',
17 | jasmineNodeOpts: {
18 | showColors: true,
19 | defaultTimeoutInterval: 30000,
20 | print: function() {}
21 | },
22 | beforeLaunch: function() {
23 | require('ts-node').register({
24 | project: 'e2e/tsconfig.e2e.json'
25 | });
26 | },
27 | onPrepare() {
28 | jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
29 | }
30 | };
31 |
--------------------------------------------------------------------------------
/src/anglarjs.ts:
--------------------------------------------------------------------------------
1 | import * as angular from 'angular';
2 | import { downgradeComponent } from '@angular/upgrade/static';
3 |
4 | import { AppComponent } from './app/app.component';
5 |
6 | export function initAngularjs() {
7 |
8 | const ng1Component: angular.IComponentOptions = {
9 | bindings: {
10 | data: '<',
11 | onUpdate: '&'
12 | },
13 | transclude: true,
14 | controller: ['$scope', 'uiGridConstants', function($scope, uiGridConstants) {
15 |
16 | const ctrl = this;
17 |
18 | const today = new Date();
19 | const nextWeek = new Date();
20 | nextWeek.setDate(nextWeek.getDate() + 7);
21 |
22 | $scope.highlightFilteredHeader = function (row, rowRenderIndex, col, colRenderIndex) {
23 | if (col.filters[0].term) {
24 | return 'header-filtered';
25 | } else {
26 | return '';
27 | }
28 | };
29 |
30 | $scope.msg = {};
31 |
32 | $scope.gridOptions = {
33 | enableFiltering: true,
34 | showGridFooter: true,
35 | showColumnFooter: true,
36 | enableSorting: true,
37 | enableColumnResizing: true,
38 | treeRowHeaderAlwaysVisible: true,
39 | enableGridMenu: true,
40 | onRegisterApi: function (gridApi) {
41 |
42 | $scope.gridApi = gridApi;
43 | gridApi.edit.on.afterCellEdit($scope, (rowEntity, colDef, newValue, oldValue) => {
44 | $scope.msg.lastCellEdited = `edited row id: ${rowEntity.id} Column: ${colDef.name} newValue: ${newValue} oldValue: ${oldValue}`;
45 | ctrl.onUpdate({
46 | 'rowId': rowEntity.id,
47 | 'column': colDef.name,
48 | 'new': newValue,
49 | 'old': oldValue
50 | });
51 | $scope.$apply();
52 | });
53 | }
54 | };
55 |
56 | $scope.toggleFiltering = function () {
57 | $scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering;
58 | $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
59 | };
60 |
61 | function makeColDefs(row) {
62 | const colDefs = [];
63 | let exist = [];
64 |
65 | for (let i = 0; i < row.length; i++) {
66 |
67 | for (const colName in row[i]) {
68 |
69 | if (exist.indexOf(colName) === -1) {
70 |
71 | colDefs.push({
72 | 'field': colName,
73 | 'width': 200
74 | });
75 | exist.push(colName);
76 | }
77 | }
78 | }
79 | exist = undefined;
80 | return colDefs;
81 | }
82 |
83 | this.$onChanges = function(obj: { data: { currentValue: Array<{}>}}) {
84 |
85 | if (obj.data.currentValue && obj.data.currentValue.length) {
86 | const colDefs = makeColDefs(obj.data.currentValue);
87 | $scope.gridOptions.data = obj.data.currentValue;
88 | $scope.gridOptions.columnDefs = colDefs;
89 | }
90 |
91 | };
92 |
93 | this.$onInit = function() {}
94 |
95 | }],
96 | template: 'Hello, Angular 2 from angular 1!
{{msg.lastCellEdited}}'
97 | };
98 |
99 | const ng1Component2: angular.IComponentOptions = {
100 | bindings: {
101 | data: '<'
102 | },
103 | transclude: true,
104 | controller: ['$scope', 'uiGridConstants', function($scope, uiGridConstants) {
105 |
106 | const ctrl = this;
107 |
108 | const today = new Date();
109 | const nextWeek = new Date();
110 | nextWeek.setDate(nextWeek.getDate() + 7);
111 |
112 | $scope.highlightFilteredHeader = function (row, rowRenderIndex, col, colRenderIndex) {
113 | if (col.filters[0].term) {
114 | return 'header-filtered';
115 | } else {
116 | return '';
117 | }
118 | };
119 |
120 | $scope.gridOptions = {
121 | showGridFooter: true,
122 | showColumnFooter: true,
123 | enableFiltering: true,
124 | onRegisterApi: function (gridApi) {
125 | $scope.gridApi = gridApi;
126 | }
127 | };
128 |
129 | $scope.toggleFiltering = function () {
130 | $scope.gridOptions.enableFiltering = !$scope.gridOptions.enableFiltering;
131 | $scope.gridApi.core.notifyDataChange(uiGridConstants.dataChange.COLUMN);
132 | };
133 |
134 | function makeColDefs(row) {
135 | const colDefs = [];
136 | let exist = [];
137 |
138 | for (let i = 0; i < row.length; i++) {
139 |
140 | for (const colName in row[i]) {
141 |
142 | if (exist.indexOf(colName) === -1) {
143 |
144 | colDefs.push({
145 | 'field': colName,
146 | 'width': 200
147 | });
148 | exist.push(colName);
149 | }
150 | }
151 | }
152 | exist = undefined;
153 | return colDefs;
154 | }
155 |
156 | this.$onChanges = function(obj: { data: { currentValue: Array<{}>}}) {
157 |
158 | if (obj.data.currentValue.length) {
159 |
160 | const colDefs = makeColDefs(obj.data.currentValue);
161 | $scope.gridOptions.data = obj.data.currentValue;
162 | $scope.gridOptions.columnDefs = colDefs;
163 | }
164 |
165 | };
166 |
167 | this.$onInit = function() {}
168 |
169 | }],
170 | template: 'Hello, Angular 2 from angular 1! '
171 | };
172 |
173 | return angular.module('ng1Module', ['ui.grid', 'ui.grid.grouping', 'ui.grid.edit', 'ui.grid.selection'])
174 | .component('ui-grid', ng1Component)
175 | .component('ng1', ng1Component2)
176 | .directive('appRoot', downgradeComponent({ component: AppComponent }));
177 | }
178 |
--------------------------------------------------------------------------------
/src/app/app.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/src/app/app.component.css
--------------------------------------------------------------------------------
/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 | {{title}}
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 |
3 | import { TestBed, async } from '@angular/core/testing';
4 | import { AppComponent } from './app.component';
5 |
6 | describe('AppComponent', () => {
7 | beforeEach(() => {
8 | TestBed.configureTestingModule({
9 | declarations: [
10 | AppComponent
11 | ],
12 | });
13 | });
14 |
15 | it('should create the app', async(() => {
16 | let fixture = TestBed.createComponent(AppComponent);
17 | let app = fixture.debugElement.componentInstance;
18 | expect(app).toBeTruthy();
19 | }));
20 |
21 | it(`should have as title 'app works!'`, async(() => {
22 | let fixture = TestBed.createComponent(AppComponent);
23 | let app = fixture.debugElement.componentInstance;
24 | expect(app.title).toEqual('app works!');
25 | }));
26 |
27 | it('should render title in a h1 tag', async(() => {
28 | let fixture = TestBed.createComponent(AppComponent);
29 | fixture.detectChanges();
30 | let compiled = fixture.debugElement.nativeElement;
31 | expect(compiled.querySelector('h1').textContent).toContain('app works!');
32 | }));
33 | });
34 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.css']
7 | })
8 | export class AppComponent {
9 | title = 'app works!';
10 | }
11 |
--------------------------------------------------------------------------------
/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
3 | import { FormsModule } from '@angular/forms';
4 | import { HttpModule } from '@angular/http';
5 | import { RouterModule } from '@angular/router';
6 | import { UpgradeModule } from '@angular/upgrade/static';
7 |
8 | import { AppComponent } from './app.component';
9 | import { Ng1ComponentFacade } from './ng1/directive';
10 | import { GridComponent } from './ng1/grid.component';
11 | import { Route1Component } from './route1/route1.component';
12 | import { Route2Component } from './route2/route2.component';
13 |
14 | @NgModule({
15 | declarations: [
16 | AppComponent,
17 | Route1Component,
18 | GridComponent,
19 | Route2Component,
20 | Ng1ComponentFacade
21 | ],
22 | imports: [
23 | BrowserModule,
24 | FormsModule,
25 | HttpModule,
26 | UpgradeModule,
27 | RouterModule.forRoot([
28 | {
29 | path: '',
30 | pathMatch: 'full',
31 | redirectTo: 'home'
32 | },
33 | {
34 | path: 'route1',
35 | component: Route1Component
36 | },
37 | {
38 | path: 'route2',
39 | component: Route2Component
40 | },
41 | { loadChildren: 'app/home/home.module#HomeModule', path: 'home' }
42 | ],
43 | {
44 | useHash: true,
45 | initialNavigation: false
46 | }),
47 | ],
48 | entryComponents: [
49 | AppComponent
50 | ],
51 | schemas: [
52 | CUSTOM_ELEMENTS_SCHEMA
53 | ]
54 | })
55 | export class AppModule {
56 | ngDoBootstrap(): void {}
57 | }
58 |
--------------------------------------------------------------------------------
/src/app/app.routing.ts:
--------------------------------------------------------------------------------
1 | import { RouterModule, Route } from '@angular/router';
2 | import { ModuleWithProviders } from '@angular/core';
3 | import { Route1Component } from './route1/route1.component';
4 | import { Route2Component } from './route2/route2.component';
5 |
6 | const routes: Route[] = [
7 | {
8 | path: '',
9 | pathMatch: 'full',
10 | redirectTo: 'home'
11 | },
12 | {
13 | path: 'route1',
14 | component: Route1Component
15 | },
16 | {
17 | path: 'route2',
18 | component: Route2Component
19 | },
20 | { loadChildren: 'app/home/home.module#HomeModule', path: 'home' },
21 | { loadChildren: 'app/dashboard/dashboard.module#DashboardModule', path: 'dashboard' }
22 | ];
23 |
24 | export const routing: ModuleWithProviders = RouterModule.forRoot(
25 | routes,
26 | {
27 | useHash: true
28 | }
29 | );
30 |
--------------------------------------------------------------------------------
/src/app/dashboard/about/about.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/src/app/dashboard/about/about.component.css
--------------------------------------------------------------------------------
/src/app/dashboard/about/about.component.html:
--------------------------------------------------------------------------------
1 |
2 | about from dashboard works!
3 |
4 |
5 |
6 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/src/app/dashboard/about/about.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Http, Response } from "@angular/http";
3 |
4 | import "rxjs/add/operator/map";
5 |
6 | @Component({
7 | selector: 'app-dashboard-about',
8 | templateUrl: './about.component.html',
9 | styleUrls: ['./about.component.css']
10 | })
11 | export class AboutComponent {
12 | myData = [];
13 | constructor(public http: Http) {
14 |
15 | this.http
16 | .get('https://jsonplaceholder.typicode.com/users')
17 | .map((response: Response) => response.json())
18 | .subscribe((data) => {
19 | this.myData = data;
20 | });
21 | }
22 |
23 | logForm(value: any) {
24 | console.log(value);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/src/app/dashboard/dashboard.component.css
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.html:
--------------------------------------------------------------------------------
1 |
2 | dashboard works!
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { DashboardComponent } from './dashboard.component';
7 |
8 | describe('DashboardComponent', () => {
9 | let component: DashboardComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ DashboardComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(DashboardComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-dashboard',
5 | templateUrl: './dashboard.component.html',
6 | styleUrls: ['./dashboard.component.css']
7 | })
8 | export class DashboardComponent implements OnInit {
9 |
10 | constructor() { }
11 |
12 | ngOnInit() {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/app/dashboard/dashboard.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { DashboardComponent } from './dashboard.component';
4 | import { RouterModule } from "@angular/router";
5 | import { AboutComponent } from "./about/about.component";
6 | import { ReactiveFormsModule, FormsModule } from "@angular/forms";
7 | import { SharedModule } from "../shared/shared.module";
8 |
9 | @NgModule({
10 | imports: [
11 | CommonModule,
12 | ReactiveFormsModule,
13 | FormsModule,
14 | SharedModule,
15 | RouterModule.forChild([{
16 | path: "", component: DashboardComponent,
17 | children: [{
18 | path: "about",
19 | component: AboutComponent
20 | }]
21 | }])
22 | ],
23 | declarations: [DashboardComponent, AboutComponent]
24 | })
25 | export class DashboardModule { }
26 |
--------------------------------------------------------------------------------
/src/app/home/about/about.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/src/app/home/about/about.component.css
--------------------------------------------------------------------------------
/src/app/home/about/about.component.html:
--------------------------------------------------------------------------------
1 |
2 | about works!
3 |
4 |
5 |
6 |
7 |
8 |
26 |
--------------------------------------------------------------------------------
/src/app/home/about/about.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Http, Response } from "@angular/http";
3 |
4 | import "rxjs/add/operator/map";
5 |
6 | @Component({
7 | selector: 'app-about',
8 | templateUrl: './about.component.html',
9 | styleUrls: ['./about.component.css']
10 | })
11 | export class AboutComponent {
12 | myData = [];
13 | constructor(public http: Http) {
14 |
15 | this.http
16 | .get('https://jsonplaceholder.typicode.com/users')
17 | .map((response: Response) => response.json())
18 | .subscribe((data) => {
19 | this.myData = data;
20 | });
21 | }
22 |
23 | logForm(value: any) {
24 | console.log(value);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/app/home/home.component.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/vladotesanovic/ui-grid-angular2/3b888de927be2062dae9533ed3648990583d8581/src/app/home/home.component.css
--------------------------------------------------------------------------------
/src/app/home/home.component.html:
--------------------------------------------------------------------------------
1 |
2 | home works!
3 |
4 | About
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/app/home/home.component.spec.ts:
--------------------------------------------------------------------------------
1 | /* tslint:disable:no-unused-variable */
2 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
3 | import { By } from '@angular/platform-browser';
4 | import { DebugElement } from '@angular/core';
5 |
6 | import { HomeComponent } from './home.component';
7 |
8 | describe('HomeComponent', () => {
9 | let component: HomeComponent;
10 | let fixture: ComponentFixture;
11 |
12 | beforeEach(async(() => {
13 | TestBed.configureTestingModule({
14 | declarations: [ HomeComponent ]
15 | })
16 | .compileComponents();
17 | }));
18 |
19 | beforeEach(() => {
20 | fixture = TestBed.createComponent(HomeComponent);
21 | component = fixture.componentInstance;
22 | fixture.detectChanges();
23 | });
24 |
25 | it('should create', () => {
26 | expect(component).toBeTruthy();
27 | });
28 | });
29 |
--------------------------------------------------------------------------------
/src/app/home/home.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-home',
5 | templateUrl: './home.component.html',
6 | styleUrls: ['./home.component.css']
7 | })
8 | export class HomeComponent {}
9 |
--------------------------------------------------------------------------------
/src/app/home/home.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
2 | import { CommonModule } from '@angular/common';
3 | import { HomeComponent } from './home.component';
4 |
5 | import { RouterModule } from "@angular/router";
6 | import { AboutComponent } from "./about/about.component";
7 | import { Ng1TestComponentFacade } from "./ng1/grid.directive";
8 | import { GridComponent } from "./ng1/grid.component";
9 | import { ReactiveFormsModule, FormsModule } from "@angular/forms";
10 | import { SharedModule } from "../shared/shared.module";
11 |
12 | @NgModule({
13 | imports: [
14 | CommonModule,
15 | SharedModule,
16 | ReactiveFormsModule,
17 | FormsModule,
18 | RouterModule.forChild([{
19 | path: "",
20 | component: HomeComponent,
21 | children: [{
22 | path: "about",
23 | component: AboutComponent
24 | }]
25 | }])
26 | ],
27 | declarations: [
28 | HomeComponent,
29 | AboutComponent,
30 | GridComponent,
31 | Ng1TestComponentFacade
32 | ],
33 | bootstrap: [HomeComponent],
34 | schemas: [
35 | CUSTOM_ELEMENTS_SCHEMA
36 | ]
37 | })
38 | export class HomeModule {}
39 |
--------------------------------------------------------------------------------
/src/app/home/ng1/grid.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 | import { Http, Response } from "@angular/http";
3 |
4 | import "rxjs/add/operator/map";
5 |
6 | @Component({
7 | selector: 'app-grid2',
8 | template: 'Draw new grid: ',
9 | })
10 | export class GridComponent {
11 | myData = [];
12 | constructor(public http: Http) {
13 |
14 | this.http
15 | .get("https://jsonplaceholder.typicode.com/users")
16 | .map((response: Response) => response.json())
17 | .subscribe((data) => {
18 | this.myData = data;
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/home/ng1/grid.directive.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Directive, ElementRef, Injector, Input, OnInit, SimpleChanges, OnChanges, DoCheck,
3 | OnDestroy
4 | } from "@angular/core";
5 | import { UpgradeComponent } from "@angular/upgrade/static";
6 |
7 | @Directive({selector: 'ng1'})
8 | export class Ng1TestComponentFacade extends UpgradeComponent implements OnInit, OnChanges, DoCheck,
9 | OnDestroy {
10 |
11 | @Input() data: {};
12 | constructor(elementRef: ElementRef, injector: Injector) {
13 | super('ng1', elementRef, injector);
14 | }
15 |
16 | ngOnInit() { super.ngOnInit(); }
17 |
18 | ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); }
19 | ngDoCheck() { super.ngDoCheck(); }
20 | ngOnDestroy() { super.ngOnDestroy(); }
21 | }
22 |
--------------------------------------------------------------------------------
/src/app/ng1/directive.ts:
--------------------------------------------------------------------------------
1 | import {
2 | Directive, ElementRef, Injector, Input, OnInit, SimpleChanges, OnChanges, DoCheck,
3 | OnDestroy, Output, EventEmitter
4 | } from '@angular/core';
5 | import { UpgradeComponent } from '@angular/upgrade/static';
6 |
7 | @Directive({selector: 'ui-grid'})
8 | export class Ng1ComponentFacade extends UpgradeComponent implements OnInit, OnChanges, DoCheck,
9 | OnDestroy {
10 |
11 | @Input() data: {};
12 | @Output() onUpdate: EventEmitter<{}>;
13 |
14 | constructor(elementRef: ElementRef, injector: Injector) {
15 | super('ui-grid', elementRef, injector);
16 | }
17 |
18 | ngOnInit() { super.ngOnInit(); }
19 |
20 | ngOnChanges(changes: SimpleChanges) { super.ngOnChanges(changes); }
21 | ngDoCheck() { super.ngDoCheck(); }
22 | ngOnDestroy() { super.ngOnDestroy(); }
23 | }
24 |
--------------------------------------------------------------------------------
/src/app/ng1/grid.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 | import { Http, Response } from '@angular/http';
3 |
4 | import 'rxjs/add/operator/map';
5 | import { Observable } from 'rxjs/Observable';
6 |
7 | @Component({
8 | selector: 'app-grid',
9 | template: `{{ data | json }}
`,
10 | })
11 | export class GridComponent implements OnInit {
12 | data: {};
13 | myData$: Observable