问:
Angular 5 --aot Vs Angular 5 --aot=false
I use Angular 5.0.0 + rxjs ^5.5.2

When I use this command: ng serve --aot=false, my application is OK but when I use this command: ng serve --aot I have this error:

```<code>core.js:1350 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
TypeError: Cannot read property 'subscribe' of undefined
</code>```

I do not have any other messge. I can not copy/paste a part of my code because,
I do not know where this comes from.

If you have any question, I am happy you answer them.

EDIT 1:

full stack:

```<code>webpack-internal:///../../../core/esm5/core.js:1546 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
TypeError: Cannot read property 'subscribe' of undefined
    at createDirectiveInstance (webpack-internal:///../../../core/esm5/core.js:12211)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13645)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at createRootView (webpack-internal:///../../../core/esm5/core.js:13535)
    at callWithDebugContext (webpack-internal:///../../../core/esm5/core.js:14936)
    at createDirectiveInstance (webpack-internal:///../../../core/esm5/core.js:12211)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13645)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at createRootView (webpack-internal:///../../../core/esm5/core.js:13535)
    at callWithDebugContext (webpack-internal:///../../../core/esm5/core.js:14936)
    at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:783)
    at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:754)
    at eval (webpack-internal:///../../../../zone.js/dist/zone.js:831)
    at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:424)
    at Object.onInvokeTask (webpack-internal:///../../../core/esm5/core.js:4816)
    at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:423)
    at Zone.runTask (webpack-internal:///../../../../zone.js/dist/zone.js:191)
    at drainMicroTaskQueue (webpack-internal:///../../../../zone.js/dist/zone.js:595)
    at ZoneTask.invokeTask [as invoke] (webpack-internal:///../../../../zone.js/dist/zone.js:502)
    at invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:1364)
defaultErrorLogger @ webpack-internal:///../../../core/esm5/core.js:1546
</code>```

EDIT 2:

ng lint command result:

```ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[8, 7]: comment must start with a space
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[10, 20]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[11, 19]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[16, 20]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[34, 9]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-routing.module.ts[28, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/badge/badge.component.ts[3, 12]: The selector of the component "BadgeComponent" shou
ld have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/legend/legend.component.ts[4, 13]: The selector of the component "LegendComponent" s
hould have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/logo/logo.component.ts[9, 30]: Type string trivially inferred from a string literal,
 remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/logo/logo.component.ts[3, 12]: The selector of the component "LogoComponent" should
have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/directives/track_scroll/track_scroll.directive.ts[12, 40]: == should be ===
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/directives/track_scroll/track_scroll.directive.ts[4, 24]: The selector of the directive "TrackS
crollDirective" should have prefix "app" (https://angular.io/styleguide#style-02-08)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[54, 13]: while statements must be braced
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[23, 25]: Type boolean trivially inferred from a boolean literal, remove type
annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[39, 36]: Type number trivially inferred from a number literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[40, 36]: Type number trivially inferred from a number literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[41, 22]: Type string trivially inferred from a string literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/404/page-not-found.component.ts[5, 12]: The selector of the component "PageNotFoundCompon
ent" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[17, 14]: Type number trivially inferred from a number li
teral, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[18, 17]: Type number trivially inferred from a number li
teral, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[19, 22]: Type boolean trivially inferred from a boolean
literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[20, 15]: Type boolean trivially inferred from a boolean
literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[50, 17]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[25, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[42, 17]: Identifier 'me' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[6, 12]: The selector of the component "CustomersComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/dashboard/dashboard.component.ts[4, 12]: The selector of the component "DashboardComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[20, 9]: Forbidden 'var' keyword, use 'let' or 'const' in
stead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[34, 9]: Forbidden 'var' keyword, use 'let' or 'const' in
stead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[20, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[34, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[7, 15]: The selector of the component "EmployeesComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[13, 12]: Type string trivially inferred from a string literal, r
emove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[39, 21]: expected a 'break' before 'case'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[41, 21]: expected a 'break' before 'case'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[43, 21]: expected a 'break' before 'default'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[6, 15]: The selector of the component "LoginComponent" should ha
ve prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/logout/logout.component.ts[5, 15]: The selector of the component "LogoutComponent" should
 have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[17, 26]: Type boolean trivially inferred from a
boolean literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[106, 9]: Forbidden 'var' keyword, use 'let' or '
const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[106, 13]: Identifier 'me' is never reassigned; u
se 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[8, 12]: The selector of the component "OrderDeta
ilsComponent" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[29, 9]: Forbidden 'var' keyword, use 'let' or 'const
' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[34, 9]: Forbidden 'var' keyword, use 'let' or 'const
' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[29, 13]: Identifier 'me' is never reassigned; use 'c
onst' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[34, 13]: Identifier 'me' is never reassigned; use 'c
onst' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[16, 23]: expected nospace before colon in property-d
eclaration
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[9, 12]: The selector of the component "OrderStatsCom
ponent" should be named kebab-case and include dash (https://angular.io/styleguide#style-05-02)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[19, 15]: Type boolean trivially inferred from a boolean litera
l, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[23, 9]: Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[40, 9]: Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[23, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[40, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[41, 13]: Identifier 'legendColors' is never reassigned; use 'c
onst' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[8, 12]: The selector of the component "OrdersComponent" should
 have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[9, 1]: space indentation expected
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[10, 1]: space indentation expected
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[22, 9]: Forbidden 'var' keyword, use 'let' or 'c
onst' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[27, 9]: Forbidden 'var' keyword, use 'let' or 'c
onst' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[22, 13]: Identifier 'me' is never reassigned; us
e 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[27, 13]: Identifier 'me' is never reassigned; us
e 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[9, 12]: The selector of the component "ProductSt
atsComponent" should be named kebab-case and include dash (https://angular.io/styleguide#style-05-02)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[21, 5]: Implement lifecycle hook interface OnIni
t for method ngOnInit in class ProductStatsComponent (https://angular.io/styleguide#style-09-01)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[27, 13]: Identifier 'headers' is never reassigned; use 'con
st' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[28, 13]: Identifier 'token' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[54, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[55, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[67, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[68, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[80, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[81, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[93, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[94, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[37, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[28, 25]: Identifier 'newRow' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[27, 21]: Identifier 'items' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[34, 21]: Identifier 'returnObj' is never reassigned; use 'cons
t' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[18, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[19, 13]: Identifier 'params' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[23, 13]: Identifier 'customerListSubject' is never reassigned;
 use 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[3, 53]: This import is blacklisted, import a submodule instead

ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[17, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[18, 13]: Identifier 'params' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[19, 24]: Type string trivially inferred from a string literal, re
move type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[57, 17]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[29, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[31, 13]: Identifier 'bodyData' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[35, 13]: Identifier 'loginDataSubject' is never reassigned; use '
const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[63, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[30, 25]: Identifier 'newRow' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[29, 21]: Identifier 'returnObj' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[22, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[23, 13]: Identifier 'params' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[26, 13]: Identifier 'orderListSubject' is never reassigned; use '
const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[56, 25]: Identifier 'newRow' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[55, 21]: Identifier 'returnObj' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[47, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[48, 13]: Identifier 'params' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[52, 13]: Identifier 'orderDetailSubject' is never reassigned; use
 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[17, 11]: comment must start with a space
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[27, 25]: Identifier 'newRow' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[26, 21]: Identifier 'returnObj' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[18, 13]: Identifier 'me' is never reassigned; use 'const' inste
ad of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[19, 13]: Identifier 'params' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[23, 13]: Identifier 'productList' is never reassigned; use 'con
st' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/auth_guard.service.ts[16, 13]: Identifier 'url' is never reassigned; use 'const' inste
ad of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[20, 27]: Type string trivially inferred from a string literal, re
move type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[47, 9]: misplaced 'catch'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[43, 13]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[40, 21]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[38, 17]: Identifier 'userInfoString' is never reassigned; use 'co
nst' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[58, 13]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[66, 13]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.
```

答:
some people down voted while there was a real bug in the ngx-datatable library:

https://github.com/swimlane/ngx-datatable/issues/1114
 and https://github.com/swimlane/ngx-datatable/issues/1104

Problem present in version 11.0.3 and solve in version 11.0.4

upgrade your pakage.json =>

"@swimlane/ngx-datatable": "^11.0.4",

Body:
I use Angular 5.0.0 + rxjs ^5.5.2

When I use this command: ng serve --aot=false, my application is OK but when I use this command: ng serve --aot I have this error:

core.js:1350 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
TypeError: Cannot read property 'subscribe' of undefined

I do not have any other messge. I can not copy/paste a part of my code because,
I do not know where this comes from.

If you have any question, I am happy you answer them.

EDIT 1:

full stack:

webpack-internal:///../../../core/esm5/core.js:1546 ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'subscribe' of undefined
TypeError: Cannot read property 'subscribe' of undefined
    at createDirectiveInstance (webpack-internal:///../../../core/esm5/core.js:12211)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13645)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at createRootView (webpack-internal:///../../../core/esm5/core.js:13535)
    at callWithDebugContext (webpack-internal:///../../../core/esm5/core.js:14936)
    at createDirectiveInstance (webpack-internal:///../../../core/esm5/core.js:12211)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13645)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at callViewAction (webpack-internal:///../../../core/esm5/core.js:14077)
    at execComponentViewsAction (webpack-internal:///../../../core/esm5/core.js:13986)
    at createViewNodes (webpack-internal:///../../../core/esm5/core.js:13673)
    at createRootView (webpack-internal:///../../../core/esm5/core.js:13535)
    at callWithDebugContext (webpack-internal:///../../../core/esm5/core.js:14936)
    at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:783)
    at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:754)
    at eval (webpack-internal:///../../../../zone.js/dist/zone.js:831)
    at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:424)
    at Object.onInvokeTask (webpack-internal:///../../../core/esm5/core.js:4816)
    at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:423)
    at Zone.runTask (webpack-internal:///../../../../zone.js/dist/zone.js:191)
    at drainMicroTaskQueue (webpack-internal:///../../../../zone.js/dist/zone.js:595)
    at ZoneTask.invokeTask [as invoke] (webpack-internal:///../../../../zone.js/dist/zone.js:502)
    at invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:1364)
defaultErrorLogger @ webpack-internal:///../../../core/esm5/core.js:1546

EDIT 2:

ng lint command result:

ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[8, 7]: comment must start with a space
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[10, 20]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[11, 19]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[16, 20]: Type string trivially inferred from a string literal, remove type annota
tion
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-config.ts[34, 9]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/app-routing.module.ts[28, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/badge/badge.component.ts[3, 12]: The selector of the component "BadgeComponent" shou
ld have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/legend/legend.component.ts[4, 13]: The selector of the component "LegendComponent" s
hould have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/logo/logo.component.ts[9, 30]: Type string trivially inferred from a string literal,
 remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/components/logo/logo.component.ts[3, 12]: The selector of the component "LogoComponent" should
have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/directives/track_scroll/track_scroll.directive.ts[12, 40]: == should be ===
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/directives/track_scroll/track_scroll.directive.ts[4, 24]: The selector of the directive "TrackS
crollDirective" should have prefix "app" (https://angular.io/styleguide#style-02-08)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[54, 13]: while statements must be braced
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[23, 25]: Type boolean trivially inferred from a boolean literal, remove type
annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[39, 36]: Type number trivially inferred from a number literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[40, 36]: Type number trivially inferred from a number literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/home.component.ts[41, 22]: Type string trivially inferred from a string literal, remove type an
notation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/404/page-not-found.component.ts[5, 12]: The selector of the component "PageNotFoundCompon
ent" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[17, 14]: Type number trivially inferred from a number li
teral, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[18, 17]: Type number trivially inferred from a number li
teral, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[19, 22]: Type boolean trivially inferred from a boolean
literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[20, 15]: Type boolean trivially inferred from a boolean
literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[50, 17]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[25, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[42, 17]: Identifier 'me' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/customers/customers.component.ts[6, 12]: The selector of the component "CustomersComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/dashboard/dashboard.component.ts[4, 12]: The selector of the component "DashboardComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[20, 9]: Forbidden 'var' keyword, use 'let' or 'const' in
stead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[34, 9]: Forbidden 'var' keyword, use 'let' or 'const' in
stead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[20, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[34, 13]: Identifier 'me' is never reassigned; use 'const
' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/employees/employees.component.ts[7, 15]: The selector of the component "EmployeesComponen
t" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[13, 12]: Type string trivially inferred from a string literal, r
emove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[39, 21]: expected a 'break' before 'case'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[41, 21]: expected a 'break' before 'case'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[43, 21]: expected a 'break' before 'default'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/login/login.component.ts[6, 15]: The selector of the component "LoginComponent" should ha
ve prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/logout/logout.component.ts[5, 15]: The selector of the component "LogoutComponent" should
 have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[17, 26]: Type boolean trivially inferred from a
boolean literal, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[106, 9]: Forbidden 'var' keyword, use 'let' or '
const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[106, 13]: Identifier 'me' is never reassigned; u
se 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_details/order_details.component.ts[8, 12]: The selector of the component "OrderDeta
ilsComponent" should have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[29, 9]: Forbidden 'var' keyword, use 'let' or 'const
' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[34, 9]: Forbidden 'var' keyword, use 'let' or 'const
' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[29, 13]: Identifier 'me' is never reassigned; use 'c
onst' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[34, 13]: Identifier 'me' is never reassigned; use 'c
onst' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[16, 23]: expected nospace before colon in property-d
eclaration
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/order_stats/order_stats.component.ts[9, 12]: The selector of the component "OrderStatsCom
ponent" should be named kebab-case and include dash (https://angular.io/styleguide#style-05-02)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[19, 15]: Type boolean trivially inferred from a boolean litera
l, remove type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[23, 9]: Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[40, 9]: Forbidden 'var' keyword, use 'let' or 'const' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[23, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[40, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[41, 13]: Identifier 'legendColors' is never reassigned; use 'c
onst' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/orders/orders.component.ts[8, 12]: The selector of the component "OrdersComponent" should
 have prefix "app" (https://angular.io/styleguide#style-02-07)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[9, 1]: space indentation expected
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[10, 1]: space indentation expected
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[22, 9]: Forbidden 'var' keyword, use 'let' or 'c
onst' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[27, 9]: Forbidden 'var' keyword, use 'let' or 'c
onst' instead
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[22, 13]: Identifier 'me' is never reassigned; us
e 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[27, 13]: Identifier 'me' is never reassigned; us
e 'const' instead of 'var'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[9, 12]: The selector of the component "ProductSt
atsComponent" should be named kebab-case and include dash (https://angular.io/styleguide#style-05-02)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/pages/product_stats/product_stats.component.ts[21, 5]: Implement lifecycle hook interface OnIni
t for method ngOnInit in class ProductStatsComponent (https://angular.io/styleguide#style-09-01)
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[27, 13]: Identifier 'headers' is never reassigned; use 'con
st' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[28, 13]: Identifier 'token' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[54, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[55, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[67, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[68, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[80, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[81, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[93, 13]: Identifier 'me' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/api-request.service.ts[94, 13]: Identifier 'requestOptions' is never reassigned; u
se 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[37, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[28, 25]: Identifier 'newRow' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[27, 21]: Identifier 'items' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[34, 21]: Identifier 'returnObj' is never reassigned; use 'cons
t' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[18, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[19, 13]: Identifier 'params' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/customer.service.ts[23, 13]: Identifier 'customerListSubject' is never reassigned;
 use 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[3, 53]: This import is blacklisted, import a submodule instead

ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[17, 13]: Identifier 'me' is never reassigned; use 'const' inst
ead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/employee.service.ts[18, 13]: Identifier 'params' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[19, 24]: Type string trivially inferred from a string literal, re
move type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[57, 17]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[29, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[31, 13]: Identifier 'bodyData' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/login.service.ts[35, 13]: Identifier 'loginDataSubject' is never reassigned; use '
const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[63, 1]: Exceeds maximum line length of 140
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[30, 25]: Identifier 'newRow' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[29, 21]: Identifier 'returnObj' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[22, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[23, 13]: Identifier 'params' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[26, 13]: Identifier 'orderListSubject' is never reassigned; use '
const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[56, 25]: Identifier 'newRow' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[55, 21]: Identifier 'returnObj' is never reassigned; use 'const'
instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[47, 13]: Identifier 'me' is never reassigned; use 'const' instead
 of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[48, 13]: Identifier 'params' is never reassigned; use 'const' ins
tead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/order.service.ts[52, 13]: Identifier 'orderDetailSubject' is never reassigned; use
 'const' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[17, 11]: comment must start with a space
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[27, 25]: Identifier 'newRow' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[26, 21]: Identifier 'returnObj' is never reassigned; use 'const
' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[18, 13]: Identifier 'me' is never reassigned; use 'const' inste
ad of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[19, 13]: Identifier 'params' is never reassigned; use 'const' i
nstead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/api/product.service.ts[23, 13]: Identifier 'productList' is never reassigned; use 'con
st' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/auth_guard.service.ts[16, 13]: Identifier 'url' is never reassigned; use 'const' inste
ad of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[20, 27]: Type string trivially inferred from a string literal, re
move type annotation
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[47, 9]: misplaced 'catch'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[43, 13]: misplaced 'else'
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[40, 21]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[38, 17]: Identifier 'userInfoString' is never reassigned; use 'co
nst' instead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[58, 13]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.
ERROR: C:/workspace/POC/Angular-SpringBoot-REST-JWT-SGR/webui/src/app/services/user-info.service.ts[66, 13]: Identifier 'userObj' is never reassigned; use 'const' in
stead of 'let'.


来源: stackexchange

问:
IIS | PHP Error: No input file specified
im running IIS 7.5 / PHP 7.0 CGI. If i open a non exist .php file i get this error:

No input file specified.

IIS don't use the 404 Error Page, like in .html files. I found some solutions, for example set doc_root in php.ini or comment out open_basedir .. but it won't help.

答: I found the solution: IIS 7 > Site > Handler Mappings > Edit handler > Request Restrictions > Mapping tab > Check "Invoke Handler only if request is mapped to:" > Select "File or folder"</p>

ContentLicense: CC BY-SA 3.0


问:
How to the JVM to use a given jaas.conf file?
How to I setup the JVM to use a given jaas.conf I created as JAAS setup? Maybe there is a JAAS picks up a configuration property which I can set on startup with -D?

答:
-Djava.security.auth.login.config=/yourpathtojaas.conf

Hope this will help you

OwnerDisplayName: Alessandro Vernet

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: DirtyAffairs


问:
Java - Do object references get destroyed when the creating class is closed?
Say i have a class, which loads a file and then calls another method to do something to that file. For example, counting the words in the file.

Within class CountWords, a number of objects/collections are created in order to get the number of words. The method runs, the number of words is found, and then this is returned to the calling class.

My question is, do all the objects/collection created in the CountWords class get "destroyed" when control is returned to the calling class or do they remain in the memory? If the latter, would i have to set each object to null before exiting the class to mark them for collection?

答:
We don't generally control exactly when a Java object gets destroyed.  It will get destroyed some time after it becomes inaccessible - in other words, when there are no further references to it in any scope.

If you create an object, and store a reference to it in a field of another object, then the object you created continues to be accessible for as long as the object that has the reference to it is accessible.

If you have code like this

```<code>public void run() {
    Foo a = new Foo();
    System.out.println("This method is finished");
}
</code>```

then the Foo that you created will be inaccessible as soon as run finishes, because there are no more variables with references to it.  Foo will be destroyed some time afterwards.  Unless of course, the constructor of Foo does some magic to register itself in some nasty static data store somewhere.

So in general, you don't need to go round setting references to null to destroy objects.  From the point of view of the garbage collector, letting those references go out of scope is just as good as setting them to null.

Body:
We don't generally control exactly when a Java object gets destroyed.  It will get destroyed some time after it becomes inaccessible - in other words, when there are no further references to it in any scope.

If you create an object, and store a reference to it in a field of another object, then the object you created continues to be accessible for as long as the object that has the reference to it is accessible.

If you have code like this

public void run() {
    Foo a = new Foo();
    System.out.println("This method is finished");
}

then the Foo that you created will be inaccessible as soon as run finishes, because there are no more variables with references to it.  Foo will be destroyed some time afterwards.  Unless of course, the constructor of Foo does some magic to register itself in some nasty static data store somewhere.

So in general, you don't need to go round setting references to null to destroy objects.  From the point of view of the garbage collector, letting those references go out of scope is just as good as setting them to null.


问:
Trying to retrieve data from URL and store in a local DB and then append to a listview
I was trying to retrieve data from URL and store it in a local DB and then appending that data to listview.
I was trying to new so please dont mind if the code have big mistakes or wrong procedure... suggest me how to do it.

my Database class is

```<code>public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;

// Database Name
private static final String DATABASE_NAME = "placesmanager";

// Contacts table name
private static final String TABLE_PLACES = "places";
public DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table if not exists TABLE_PLACES(name varchar(50),rating varchar(50),icon varchar(50))");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_PLACES);

    // Create tables again
    onCreate(db);

}
//adding contact
public void addContact(PlacesData data) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("name", data.getName());
    values.put("rating", data.getRating());
    values.put("icon", data.getIcon());

    // Inserting Row
    db.insert(TABLE_PLACES, null, values);
    db.close(); // Closing database connection
}

// Getting All Contacts
public ArrayList<PlacesData> getAllContacts() {
    ArrayList<PlacesData> contactList = new ArrayList<>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + TABLE_PLACES;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
        do {
            PlacesData contact = new PlacesData();
            contact.setName(cursor.getString(0));
            contact.setRating(cursor.getString(1));
            contact.setIcon(cursor.getString(2));
            // Adding contact to list
            contactList.add(contact);
        } while (cursor.moveToNext());
    }

    // return contact list
    return contactList;
}
</code>```

and the method of recyclerview that iam appending to Database and trying to retrive it is

```<code> public void onBindViewHolder(MyRecycler holder, final int position) {

    DatabaseHandler handler = new DatabaseHandler(activity);
    handler.addContact(new PlacesData(data.get(position).getName(),data.get(position).getRating(),data.get(position).getIcon()));
  //  Log.i("Database",handler+"");

    ArrayList<PlacesData> contacts = handler.getAllContacts();

    for (PlacesData cn : contacts) {
        String log = "Name: "+cn.getName()+" ,Rating: " + cn.getRating() + " ,Icon: " + cn.getIcon();
        Log.i("Name: ", log);
        holder.tvName.setText(cn.getName());
        holder.tvRating.setText(cn.getRating());
        Picasso.with(activity).load(cn.getIcon()).into(holder.imgIcon);
    }
        }
    });
</code>```

Appending the DB data to recyclerview is done, but not in correct way the fields are repeating in view.and in Android Monitor the following  error is showing.

I am doing this by following some google examples suggest me possible changes.

and finally the output is

答:
Make your adapter class like this

```<code>public class PlacesDataAdapter extends RecyclerView.Adapter<PlacesDataAdapter.Viewholder>
{

    ArrayList<PlacesData> PlacesDatalist;
    Context context;
    LayoutInflater inflater;

    public PlacesDataAdapter(Context context,ArrayList<PlacesData> PlacesDatalist){
        this.context=context;
        this.surveylist=PlacesDatalist;
        inflater= LayoutInflater.from(context);

    }
    @Override
    public Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {

        final View view=inflater.inflate(R.layout.single_row,parent,false);
        return new Viewholder(view);
    }

    @Override
    public void onBindViewHolder(Viewholder holder, int position)
    {
            final PlacesData placedata=surveylist.get(position);

            holder.tvName.setText(placedata.getName());
            holder.tvRating.setText(placedata.getRating());

    }

    @Override
    public int getItemCount() {
        return PlacesDatalist.size();
    }

}
</code>```

fetching the data from local database,in your activity(Clear the arraylist every time so that value will not repeat in your list means do "contacts.clear" )

```<code>ArrayList<PlacesData> contacts = handler.getAllContacts();
</code>```

after that just make an object of your adapter class and pass arraylist inside this and do notifydatasetchange.

```<code>PlacesDataAdapter adapter=new SurveyAdapter(this,contacts);
adapter.notifyDataSetChanged();
</code>```

Body:
I was trying to retrieve data from URL and store it in a local DB and then appending that data to listview.
I was trying to new so please dont mind if the code have big mistakes or wrong procedure... suggest me how to do it.

my Database class is

public class DatabaseHandler extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;

// Database Name
private static final String DATABASE_NAME = "placesmanager";

// Contacts table name
private static final String TABLE_PLACES = "places";
public DatabaseHandler(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
    db.execSQL("create table if not exists TABLE_PLACES(name varchar(50),rating varchar(50),icon varchar(50))");

}

@Override
public void onUpgrade(SQLiteDatabase db, int i, int i1) {
    db.execSQL("DROP TABLE IF EXISTS " + TABLE_PLACES);

    // Create tables again
    onCreate(db);

}
//adding contact
public void addContact(PlacesData data) {
    SQLiteDatabase db = this.getWritableDatabase();

    ContentValues values = new ContentValues();
    values.put("name", data.getName());
    values.put("rating", data.getRating());
    values.put("icon", data.getIcon());

    // Inserting Row
    db.insert(TABLE_PLACES, null, values);
    db.close(); // Closing database connection
}

// Getting All Contacts
public ArrayList<PlacesData> getAllContacts() {
    ArrayList<PlacesData> contactList = new ArrayList<>();
    // Select All Query
    String selectQuery = "SELECT  * FROM " + TABLE_PLACES;

    SQLiteDatabase db = this.getWritableDatabase();
    Cursor cursor = db.rawQuery(selectQuery, null);

    // looping through all rows and adding to list
    if (cursor.moveToFirst()) {
        do {
            PlacesData contact = new PlacesData();
            contact.setName(cursor.getString(0));
            contact.setRating(cursor.getString(1));
            contact.setIcon(cursor.getString(2));
            // Adding contact to list
            contactList.add(contact);
        } while (cursor.moveToNext());
    }

    // return contact list
    return contactList;
}

and the method of recyclerview that iam appending to Database and trying to retrive it is

 public void onBindViewHolder(MyRecycler holder, final int position) {

    DatabaseHandler handler = new DatabaseHandler(activity);
    handler.addContact(new PlacesData(data.get(position).getName(),data.get(position).getRating(),data.get(position).getIcon()));
  //  Log.i("Database",handler+"");

    ArrayList<PlacesData> contacts = handler.getAllContacts();

    for (PlacesData cn : contacts) {
        String log = "Name: "+cn.getName()+" ,Rating: " + cn.getRating() + " ,Icon: " + cn.getIcon();
        Log.i("Name: ", log);
        holder.tvName.setText(cn.getName());
        holder.tvRating.setText(cn.getRating());
        Picasso.with(activity).load(cn.getIcon()).into(holder.imgIcon);
    }
        }
    });

Appending the DB data to recyclerview is done, but not in correct way the fields are repeating in view.and in Android Monitor the following  error is showing.

I am doing this by following some google examples suggest me possible changes.

and finally the output is

Body:
Make your adapter class like this

public class PlacesDataAdapter extends RecyclerView.Adapter<PlacesDataAdapter.Viewholder>
{

    ArrayList<PlacesData> PlacesDatalist;
    Context context;
    LayoutInflater inflater;

    public PlacesDataAdapter(Context context,ArrayList<PlacesData> PlacesDatalist){
        this.context=context;
        this.surveylist=PlacesDatalist;
        inflater= LayoutInflater.from(context);

    }
    @Override
    public Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {

        final View view=inflater.inflate(R.layout.single_row,parent,false);
        return new Viewholder(view);
    }

    @Override
    public void onBindViewHolder(Viewholder holder, int position)
    {
            final PlacesData placedata=surveylist.get(position);

            holder.tvName.setText(placedata.getName());
            holder.tvRating.setText(placedata.getRating());

    }

    @Override
    public int getItemCount() {
        return PlacesDatalist.size();
    }

}

fetching the data from local database,in your activity(Clear the arraylist every time so that value will not repeat in your list means do "contacts.clear" )

ArrayList<PlacesData> contacts = handler.getAllContacts();

after that just make an object of your adapter class and pass arraylist inside this and do notifydatasetchange.

PlacesDataAdapter adapter=new SurveyAdapter(this,contacts);
adapter.notifyDataSetChanged();


问:
Wireless low-level API?
I am looking for an API that will allow me to manipulate wireless hardware very near the metal. For example, I would like to be able to build an application that simultaneously connects to multiple peers (physically close peers) as well as some access point like a legacy Wifi Router.

Is there any such library?

答:
You will be limited by the recent FCC ruling that prohibits router manufactures from allowing the consumer access to the diver level functions specifically for 5Ghz.

https://www.wired.com/2016/03/way-go-fcc-now-manufacturers-locking-routers/

Because of this you may want to use a older router with OpenWrt.  OpenWRT should allow you the ability to configure the router in a variety of ways.

Title: Wireless low-level API?


问:
Custom build task is not deleted
I'm trying to delete a Build Task using tfx-cli.

```<code>C:\Users\Work>tfx build tasks list
TFS Cross Platform Command Line Interface v0.4.11
Copyright Microsoft Corporation

id            : 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9
name          : VersionAssembly
friendly name : Version Assembly
visibility    : Build
description   : Update the assembly version number to match the build number
version       : 1.0.9
</code>```

I now have the Task ID.

```<code>C:\Users\Work>tfx build tasks delete --task-id 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9
TFS Cross Platform Command Line Interface v0.4.11
Copyright Microsoft Corporation

Task 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9 deleted successfully!
</code>```

But even after a Ctrl+F5 Refresh, the task still shows up in TFS:

Running the delete command again shows the same thing. Success. Not "Can't be found," or some such thing.

How to get rid of this pesky bugger?

答:
I was able to delete the Task via the REST API:

```<code>$Credential = Get-Credential
$Headers = @{ "Accept" = "application/json; api-version=2.0"; "X-TFS-FedAuthRedirect" = "Suppress" }
$Uri = "http://hostname:8080/tfs/_apis/distributedtask/tasks/122d5ad0-61a1-11e6-b9c1-5b12bd371fa9"

Invoke-RestMethod -Credential $Credential -Headers $Headers -Uri $Uri -Method Delete
</code>```

Following on Jesse Houwing's suggestion, my theory is that because it was created with the API in the first place (my recollection in my comment above is incorrect), it also had to be deleted with the API.

Title: Custom build task is not deleted

Body:
I'm trying to delete a Build Task using tfx-cli.

C:\Users\Work>tfx build tasks list
TFS Cross Platform Command Line Interface v0.4.11
Copyright Microsoft Corporation

id            : 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9
name          : VersionAssembly
friendly name : Version Assembly
visibility    : Build
description   : Update the assembly version number to match the build number
version       : 1.0.9

I now have the Task ID.

C:\Users\Work>tfx build tasks delete --task-id 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9
TFS Cross Platform Command Line Interface v0.4.11
Copyright Microsoft Corporation

Task 122d5ad0-61a1-11e6-b9c1-5b12bd371fa9 deleted successfully!

But even after a Ctrl+F5 Refresh, the task still shows up in TFS:

Running the delete command again shows the same thing. Success. Not "Can't be found," or some such thing.

How to get rid of this pesky bugger?

Body:
I was able to delete the Task via the REST API:

$Credential = Get-Credential
$Headers = @{ "Accept" = "application/json; api-version=2.0"; "X-TFS-FedAuthRedirect" = "Suppress" }
$Uri = "http://hostname:8080/tfs/_apis/distributedtask/tasks/122d5ad0-61a1-11e6-b9c1-5b12bd371fa9"

Invoke-RestMethod -Credential $Credential -Headers $Headers -Uri $Uri -Method Delete

Following on Jesse Houwing's suggestion, my theory is that because it was created with the API in the first place (my recollection in my comment above is incorrect), it also had to be deleted with the API.


问:
Dismiss keyboard in iOS
I looked at and tried multiple solutions for Swift 3, Xcode 8 but couldn't get any to work. I've tried:

```<code>override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.view.endEditing(true)
}
</code>```

and also setting a text field input as first responder:

```<code>override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    pressureInput.resignFirstResponder()
}
</code>```

I don't know if something from Xcode 8 to Xcode 9 that cause these methods to not work, or if I messed elsewhere. I have 9 text fields and they've all set delegate to self. Their tags are incremented to move on to the next text field on pressing return. Don't think that would affect it. Sorry, new at this! The code runs fine with either of those attempted functions, but they keyboard stays. I would just like to dismiss keyboard when touched outside of any text field.

答:
Are you sure that touchesBegan is being called? If you're sure, try adding self.resignFirstResponder() to your touchesBegan function. This tells your view controller that it's no longer the first responder and should dismiss the keyboard.

If not, what you'll want to do is create a UITapGestureRecognizer, add it to your view, and wire it to a function that calls self.resignFirstResponder().

Title: Dismiss keyboard in iOS

Body:
I looked at and tried multiple solutions for Swift 3, Xcode 8 but couldn't get any to work. I've tried:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    self.view.endEditing(true)
}

and also setting a text field input as first responder:

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
    pressureInput.resignFirstResponder()
}

I don't know if something from Xcode 8 to Xcode 9 that cause these methods to not work, or if I messed elsewhere. I have 9 text fields and they've all set delegate to self. Their tags are incremented to move on to the next text field on pressing return. Don't think that would affect it. Sorry, new at this! The code runs fine with either of those attempted functions, but they keyboard stays. I would just like to dismiss keyboard when touched outside of any text field.


问:
Selecting MySql table data into an array
I try to catch data from mysql to put them all in array.
Suppose:

```<code>    users table
    -----------------------
    id| name | code
    ----------------------
    1| gorge | 2132
    2| flix | ksd02
    3| jasmen | skaod2

    $sql = mysql_query("select id, name, code from users");
    $userinfo = array()
    while($row_user = mysql_fetch_array($sql)){
    $userinfo = $row_user[name]
    }
-------------------------
foreach($userinfo as $usinfo){
echo $usinfo."<br/>";
}
</code>```

Here is the problem i can only insert user name but cant insert also code & id in userinfo array please help me to insert all data in same array.

[P.S] No object oriented please.

答:
```<code>$sql = mysql_query("select id, name, code from users");
$userinfo = array();

while ($row_user = mysql_fetch_assoc($sql))
    $userinfo[] = $row_user;
</code>```

This will give you $userinfo as an array with the following structure:

```<code>[
    [id => 1, name => 'gorge', code => '2123'],
    [id => 2, name => 'flix', code => 'ksd02'],
    [id => 3, name => 'jasmen', code => 'skaod2']
]
</code>```

If you want to output the data:

```<code>foreach ($userinfo as $user) {
    echo "Id: {$user[id]}<br />"
       . "Name: {$user[name]}<br />"
       . "Code: {$user[code]}<br /><br />";
}
</code>```

Body:
I try to catch data from mysql to put them all in array.
Suppose:

    users table
    -----------------------
    id| name | code
    ----------------------
    1| gorge | 2132
    2| flix | ksd02
    3| jasmen | skaod2

    $sql = mysql_query("select id, name, code from users");
    $userinfo = array()
    while($row_user = mysql_fetch_array($sql)){
    $userinfo = $row_user[name]
    }
-------------------------
foreach($userinfo as $usinfo){
echo $usinfo."
";
}

Here is the problem i can only insert user name but cant insert also code & id in userinfo array please help me to insert all data in same array.

[P.S] No object oriented please.

Body:
$sql = mysql_query("select id, name, code from users");
$userinfo = array();

while ($row_user = mysql_fetch_assoc($sql))
    $userinfo[] = $row_user;

This will give you $userinfo as an array with the following structure:

[
    [id => 1, name => 'gorge', code => '2123'],
    [id => 2, name => 'flix', code => 'ksd02'],
    [id => 3, name => 'jasmen', code => 'skaod2']
]

If you want to output the data:

foreach ($userinfo as $user) {
    echo "Id: {$user[id]}<br />"
       . "Name: {$user[name]}<br />"
       . "Code: {$user[code]}<br /><br />";
}


问:
Workaround for unsupported positional operator in MongoDB C# driver for .NET core
It seems all usages of positional operators in the C# driver is unsupported when running .Net Core on Linux.

Here is an issue I reported to the MongoDB team, that unfortunately hasn't got much attention:

https://jira.mongodb.org/browse/CSHARP-2066

While we're wating for this to be fixed, does anyone know of a workaround?

答:
Usually you can resort to using JSON string based queries. So using the example you gave in the JIRA issue which looks like this:

```<code>collection.UpdateOne(
    filter: Builders<Animal>.Filter.Where(x => x.Subdocument.Subarray.Any(itm => itm.SomeProperty == "foobar")),
    update: Builders<Animal>.Update.Inc(x => x.Subdocument.Subarray[-1].SomeNumericProperty, 10)
);
</code>```

You could rewrite this as:

```<code>collection.UpdateOne(
    filter: Builders<Animal>.Filter.Where(x => x.Subdocument.Subarray.Any(itm => itm.SomeProperty == "foobar")),
    update: "{ $inc: { \"Subdocument.Subarray.$.SomeNumericProperty\": 10 } }")
);
</code>```

Body:
Usually you can resort to using JSON string based queries. So using the example you gave in the JIRA issue which looks like this:

collection.UpdateOne(
    filter: Builders<Animal>.Filter.Where(x => x.Subdocument.Subarray.Any(itm => itm.SomeProperty == "foobar")),
    update: Builders<Animal>.Update.Inc(x => x.Subdocument.Subarray[-1].SomeNumericProperty, 10)
);

You could rewrite this as:

collection.UpdateOne(
    filter: Builders<Animal>.Filter.Where(x => x.Subdocument.Subarray.Any(itm => itm.SomeProperty == "foobar")),
    update: "{ $inc: { \"Subdocument.Subarray.$.SomeNumericProperty\": 10 } }")
);


问:
Diffie-Hellman symmetry keys display issue
I am generating Symmetric-keys by using bouncy castle Diffie-Hellman key exchange protocol, but when I display my generated Secret then it gives me the following error

java.lang.IllegalStateException: Key agreement has not been completed yet

Assume from the below code that keys agreement process has be successfully completed and also from the hashes it confirms that both keys are the similar.

```<code>    MessageDigest   hash = MessageDigest.getInstance("SHA1");
    byte[] aShared = hash.digest(aKeyAgree.generateSecret());
    byte[] bShared = hash.digest(bKeyAgree.generateSecret());
    System.out.println(Arrays.toString(aKeyAgree.generateSecret()));
</code>```

答: It's probably simply that calling aKeyAgree.generateSecret() twice is the issue. The key agreement should be performed just once. If you want to print the result you need to store it in a (temporary) variable instead.

Body:
I am generating Symmetric-keys by using bouncy castle Diffie-Hellman key exchange protocol, but when I display my generated Secret then it gives me the following error

java.lang.IllegalStateException: Key agreement has not been completed yet

Assume from the below code that keys agreement process has be successfully completed and also from the hashes it confirms that both keys are the similar.

    MessageDigest   hash = MessageDigest.getInstance("SHA1");
    byte[] aShared = hash.digest(aKeyAgree.generateSecret());
    byte[] bShared = hash.digest(bKeyAgree.generateSecret());
    System.out.println(Arrays.toString(aKeyAgree.generateSecret()));


问:
vb.net date formatting vs c# datetime formatting
I am doing an Visual Studio vb.net WinForm App.

I am used to work with c#. In C# Datetime DataType I have configured as "dd/MM/yyyy" as is configured in Control Panel and Regedit.

In VB.Net, is different, when I create a Date variable like this

Dim var As New Date
var = DateTime.Now```

Date.Now returns format "mm/dd/yyyy".

So every date format a assign to a variable, VB.Net automatically convert to format "mm/dd/yyyy".

I need Date DataType in VB.Net to be configured as C#. I mean, "dd/MM/yyyy" as it is configured in Control Panel.

Is that possible?

Thanks

答:
Override the date format on Global.asax</p>

```<code>protected void Application_BeginRequest(Object sender, EventArgs e)
{
    CultureInfo newCulture = (CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
    newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
    newCulture.DateTimeFormat.DateSeparator = "/";
    Thread.CurrentThread.CurrentCulture = newCulture;
}
</code>```

Body:
I am doing an Visual Studio vb.net WinForm App.

I am used to work with c#. In C# Datetime DataType I have configured as "dd/MM/yyyy" as is configured in Control Panel and Regedit.

In VB.Net, is different, when I create a Date variable like this

Dim var As New Date
var = DateTime.Now

Date.Now returns format "mm/dd/yyyy".

So every date format a assign to a variable, VB.Net automatically convert to format "mm/dd/yyyy".

I need Date DataType in VB.Net to be configured as C#. I mean, "dd/MM/yyyy" as it is configured in Control Panel.

Is that possible?

Thanks

Body:
Override the date format on Global.asax

protected void Application_BeginRequest(Object sender, EventArgs e)
{
    CultureInfo newCulture = (CultureInfo) System.Threading.Thread.CurrentThread.CurrentCulture.Clone();
    newCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
    newCulture.DateTimeFormat.DateSeparator = "/";
    Thread.CurrentThread.CurrentCulture = newCulture;
}


问:
rowspans and colspans in html email
Can rowspans and colspans be safely used when designing table-based HTML emails?

I have been told that they don't display correctly in Outlook 2007 and that tables must be nested in order to provide different size cells for layout.

Can anybody help or provide any links? Thanks

答:
Colspans are usually safe to use. Stay away from rowspans.

Your best option is to nest a new table within a cell instead of doing rowspans or colspans.

Title: rowspans and colspans in html email


问:
Swift 4 Cannot convert value of type '[String : AnyObject]?' to expected argument type '[NSAttributedStringKey : Any]?'
I have just updated to Xcode 9 and converted my app from swift 3 to swift 4.
I have graphs which use strings to label the axes and other variables.
So I have a moneyAxisString = "Money".
Previously I was able to draw them using this code:

```<code>moneyAxisString.draw(in: CGRect(x: CGFloat(coordinateXOriginLT + axisLength/3), y: CGFloat(coordinateYOriginRT + axisLength + 5 * unitDim), width: CGFloat(300 * unitDim), height: CGFloat(100 * unitDim)), withAttributes: attributes as? [String : AnyObject])
</code>```

Where attributes is a dictionary defined as follows

```<code> attributes = [
        NSAttributedStringKey.foregroundColor: fieldColor,
        NSAttributedStringKey.font: fieldFont!,
        NSAttributedStringKey.paragraphStyle: style

    ]
</code>```

Now my app won't compile and I am getting the message:

Cannot convert value of type '[String : AnyObject]?' to expected argument type '[NSAttributedStringKey : Any]?'

答:
NSAttributedStringKey was changed to a struct in Swift 4. However, other objects that use NSAttributedStringKey apparently didn't get updated at the same time.

The easiest fix, without having to change any of your other code, is to append .rawValue to all your occurrences of NSAttributedStringKey setters - turning the key names into Strings:

```<code>let attributes = [
    NSAttributedStringKey.font.rawValue:  UIFont(name: "Helvetica-Bold", size: 15.0)!,
    NSAttributedStringKey.foregroundColor.rawValue: UIColor.white
] as [String : Any]
</code>```

Note that you won't need the ! at the as now, either.

Alternatively, you can skip the as cast at the end by declaring the array to be [String : Any] upfront:

```<code>let attributes: [String : Any] = [
    NSAttributedStringKey.font.rawValue:  UIFont(name: "Helvetica-Bold", size: 15.0)!,
    NSAttributedStringKey.foregroundColor.rawValue: UIColor.white
]
</code>```

Of course, you still need to append the .rawValue for each NSAttributedStringKey item you set.

Body:
I have just updated to Xcode 9 and converted my app from swift 3 to swift 4.
I have graphs which use strings to label the axes and other variables.
So I have a moneyAxisString = "Money".
Previously I was able to draw them using this code:

moneyAxisString.draw(in: CGRect(x: CGFloat(coordinateXOriginLT + axisLength/3), y: CGFloat(coordinateYOriginRT + axisLength + 5 * unitDim), width: CGFloat(300 * unitDim), height: CGFloat(100 * unitDim)), withAttributes: attributes as? [String : AnyObject])

Where attributes is a dictionary defined as follows

 attributes = [
        NSAttributedStringKey.foregroundColor: fieldColor,
        NSAttributedStringKey.font: fieldFont!,
        NSAttributedStringKey.paragraphStyle: style

    ]

Now my app won't compile and I am getting the message:

Cannot convert value of type '[String : AnyObject]?' to expected argument type '[NSAttributedStringKey : Any]?'

Body:
NSAttributedStringKey was changed to a struct in Swift 4. However, other objects that use NSAttributedStringKey apparently didn't get updated at the same time.

The easiest fix, without having to change any of your other code, is to append .rawValue to all your occurrences of NSAttributedStringKey setters - turning the key names into Strings:

let attributes = [
    NSAttributedStringKey.font.rawValue:  UIFont(name: "Helvetica-Bold", size: 15.0)!,
    NSAttributedStringKey.foregroundColor.rawValue: UIColor.white
] as [String : Any]

Note that you won't need the ! at the as now, either.

Alternatively, you can skip the as cast at the end by declaring the array to be [String : Any] upfront:

let attributes: [String : Any] = [
    NSAttributedStringKey.font.rawValue:  UIFont(name: "Helvetica-Bold", size: 15.0)!,
    NSAttributedStringKey.foregroundColor.rawValue: UIColor.white
]

Of course, you still need to append the .rawValue for each NSAttributedStringKey item you set.


问:
Annotate functions that return Optional with @NonNull?
Why add @NonNull annotation when returning Optional?

```<code>public Optional<Integer> getInt() {
    return Optional.ofNullable(localInteger);
}
</code>```

Vs

```<code>@NonNull
public Optional<Integer> getInt() {
    return Optional.ofNullable(localInteger);
}
</code>```

Based on this article: http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
My understanding of Optional with that article is that the whole point of Optional is to try and prevent checking for null in code and that when a function can return null it will instead return an Optional to force the caller to check if it isPresent.

I have since learned that there are issues with Optional<Map> described here: https://developer.atlassian.com/blog/2015/08/optional-broken

So adding @NonNull for Optional seems to add extra clarity to the caller when returning a Map type but is this clarity required for all functions that return any Optional type?

```<code>public Optional<Integer> getInt() {
    return null;
}
</code>```

Is as bad as

```<code>@NonNull
public Integer getInt() {
    return null;
}
</code>```

Am I correct in thinking that it is bad practise to be returning null when the return type is Optional? (except for the above mentioned Map case or because there is a case where null is valid you should always add @NonNull?)

Conclusion
My conclusion so far is to not add @NonNull when returning Optional and if it can be null then annotate with @Nullable or better yet, don't return an Optional type.

答:
Thanks for your comments. It would seem my understanding lines up with the comments.

Returning null when Optional is "promised" seems to be generally accepted as bad.

I completely agree based on the purpose of what Optional was designed for.

However... We have had to make a special note in our company docs for this due to the lack of documentation in Optional making it explicitly clear that you should not return null when returning an Optional.

Body:
Why add @NonNull annotation when returning Optional?

public Optional<Integer> getInt() {
    return Optional.ofNullable(localInteger);
}

Vs

@NonNull
public Optional<Integer> getInt() {
    return Optional.ofNullable(localInteger);
}

Based on this article: http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
My understanding of Optional with that article is that the whole point of Optional is to try and prevent checking for null in code and that when a function can return null it will instead return an Optional to force the caller to check if it isPresent.

I have since learned that there are issues with Optional<Map> described here: https://developer.atlassian.com/blog/2015/08/optional-broken

So adding @NonNull for Optional seems to add extra clarity to the caller when returning a Map type but is this clarity required for all functions that return any Optional type?

public Optional<Integer> getInt() {
    return null;
}

Is as bad as

@NonNull
public Integer getInt() {
    return null;
}

Am I correct in thinking that it is bad practise to be returning null when the return type is Optional? (except for the above mentioned Map case or because there is a case where null is valid you should always add @NonNull?)

Conclusion
My conclusion so far is to not add @NonNull when returning Optional and if it can be null then annotate with @Nullable or better yet, don't return an Optional type.


问:
Video Upload using Dot Net Core MVC to Google Cloud Storage
I'm really struggling here as I'm super new to Dot Net Core as well as Google Cloud Storage. I have looked over a lot of the available documentation online but I still can't understand on how to build the architecture.

So what I'm trying to build is a dot net core MVC application that has a form to upload a video file to Google Cloud storage (Google bucket probably?). The controller will take the data from the form and the Model layer is Google Storage.

Some pointers will be really helpful on how can I proceed about this task. Also some links to tutorials or any documentation if you guys think would be useful. Thanks a lot!!

答:
Here's a sample that help answer half your question.  It demonstrates how to upload a file to Google Cloud Storage:
https://github.com/GoogleCloudPlatform/dotnet-docs-samples/blob/master/storage/api/Storage/Program.cs#L117</p>


问:
Unwanted margin on main background image
So i'm having trouble getting rid of a small margin that appears on the background of my main index page:  This is the upper corner of it, i have a fixed navbar on top that does not share the same problem, but the background image below wont fill the entire space.

This is the css code that i'm using:

.indexmain{
    width: 100%;
    height: 1000px;
    background: url(images/main-screen.jpg) no-repeat;
    -webkit-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}```

Apparently there's no inheritance issue from any other asset, utilizing a fixed position with 'left:0' didn't work either...

答: Try adding margin-left: 0px; in the images class</p>

Body:
So i'm having trouble getting rid of a small margin that appears on the background of my main index page:  This is the upper corner of it, i have a fixed navbar on top that does not share the same problem, but the background image below wont fill the entire space.

This is the css code that i'm using:

.indexmain{
    width: 100%;
    height: 1000px;
    background: url(images/main-screen.jpg) no-repeat;
    -webkit-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

Apparently there's no inheritance issue from any other asset, utilizing a fixed position with 'left:0' didn't work either...


问:
How to run 'sudo' command in windows
How would I run the following command in windows:

```<code>$ sudo django-admin.py startproject NEW
</code>```

?

答: There is no sudo command in case of windows and also there is no need to put any $. For installing Angular CLI through node.js command prompt in windows, I just wrote npm install -g @angular/cli and then pressed Enter. It worked fine.

Title: How to run 'sudo' command in windows

Body:
How would I run the following command in windows:

$ sudo django-admin.py startproject NEW

?


问:
How to retrieve all certificates in your X509Store
I am using the following code to retrieve all certificates in my PC from an asp.net webapp. The certificates collection is empty, and I can't understand why.

I tried impersonating my own user account and I didn't succeed as well. What am I doing wrong?

```<code>var store = new X509Store(StoreLocation.CurrentUser); //StoreLocation.LocalMachine fails too
var certificates = store.Certificates;
foreach (var certificate in certificates)
{
    var friendlyName = certificate.FriendlyName;
    Console.WriteLine(friendlyName);
}

//original problem: fetch a single certificate by its subject name
X509Certificate2 clientCertificate = CertificateUtility.GetCertificate(StoreName.My, StoreLocation.CurrentUser,  "CN=mypc.domainname"); //returns null :(
</code>```

答:
Look in your certificate store(mmc/add/certificate snap-in/my user account/Certificates - Current User/Personal/Certificates) to see the subject name to make sure "CN=mypc.domainname" is whats actually on the cert.

```<code>"CN=mypc.domainname"
</code>```

vs

```<code>"CN = mypc.domainname"
</code>```

...etc

Body:
I am using the following code to retrieve all certificates in my PC from an asp.net webapp. The certificates collection is empty, and I can't understand why.

I tried impersonating my own user account and I didn't succeed as well. What am I doing wrong?

var store = new X509Store(StoreLocation.CurrentUser); //StoreLocation.LocalMachine fails too
var certificates = store.Certificates;
foreach (var certificate in certificates)
{
    var friendlyName = certificate.FriendlyName;
    Console.WriteLine(friendlyName);
}

//original problem: fetch a single certificate by its subject name
X509Certificate2 clientCertificate = CertificateUtility.GetCertificate(StoreName.My, StoreLocation.CurrentUser,  "CN=mypc.domainname"); //returns null :(

Body:
Look in your certificate store(mmc/add/certificate snap-in/my user account/Certificates - Current User/Personal/Certificates) to see the subject name to make sure "CN=mypc.domainname" is whats actually on the cert.

"CN=mypc.domainname"

vs

"CN = mypc.domainname"

...etc


问:
merge arrays and convert to JSON string
I have two arrays consist of strings
["25","36","32"] and ["GradeA", "GradeB", "GradeC"]

I want to merge them all together and want to produce JSON string something like this:

{"GradeA" : "25", "GradeB" : "36", "GradeC": "32"}

How do I do this in js?

答:
This below code will give your expected output:

 var arr1 = [25,36,32] ;
 var arr2 =  ["GradeA", "GradeB", "GradeC"];
 var gradeObj = {};
 for(var i = 0;i<arr2.length;i++){
   gradeObj[arr2[i]] = arr1[i];
 }

 console.log(JSON.stringify(gradeObj));```

Title: merge arrays and convert to JSON string


答:
Using ES6 reduce:

{
  const a = ["25","36","32"];
  const b = ["GradeA", "GradeB", "GradeC"];
  const merge = (keys, values) => keys.reduce(
    (obj, key, i) => (obj[key] = values[i], obj),
    {}
  );

  const json = JSON.stringify(
    merge(b, a)
  );
  console.log(json);
}```
</div>
</div>
</p>

<p>with native Reflect API:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
  const a = ["25","36","32"];
  const b = ["GradeA", "GradeB", "GradeC"];
  const merge = (keys, values) => keys.reduce(
    (obj, key, i) => Reflect.set(obj, key, values[i]) && obj,
    {}
  );

  const json = JSON.stringify(
    merge(b, a)
  );
  console.log(json);
}</code>```

Title: merge arrays and convert to JSON string

Body:
I have two arrays consist of strings
["25","36","32"] and ["GradeA", "GradeB", "GradeC"]

I want to merge them all together and want to produce JSON string something like this:

{"GradeA" : "25", "GradeB" : "36", "GradeC": "32"}

How do I do this in js?

Body:
Using ES6 reduce:

{
  const a = ["25","36","32"];
  const b = ["GradeA", "GradeB", "GradeC"];
  const merge = (keys, values) => keys.reduce(
    (obj, key, i) => (obj[key] = values[i], obj),
    {}
  );

  const json = JSON.stringify(
    merge(b, a)
  );
  console.log(json);
}

with native Reflect API:

{
  const a = ["25","36","32"];
  const b = ["GradeA", "GradeB", "GradeC"];
  const merge = (keys, values) => keys.reduce(
    (obj, key, i) => Reflect.set(obj, key, values[i]) && obj,
    {}
  );

  const json = JSON.stringify(
    merge(b, a)
  );
  console.log(json);
}


问:
How to use directive multiple times
Basically I have copied this code from another source which is a countdown timer.

Directive

```<code>app.directive('countdown', [
    'Util', '$interval', function (Util, $interval) {
        return {
            restrict: 'E',
            scope: {
                date: '@'
            },
            templateUrl: 'countdown_timer.html',
            link: function (scope, element) {
                var future = new Date(scope.date);

                var stop;

                stop = $interval(function () {
                    var diff;
                    diff = Math.floor((future.getTime() - new Date().getTime()) / 1000);

                    if (parseInt(diff) <= 0) {
                        stopTimer();
                        scope.days = 0;
                        scope.hours = 0;
                        scope.minutes = 0;
                        scope.seconds = 0;
                    } else {
                        var d = Util.dhms(diff);
                        scope.days = d[0];
                        scope.hours = d[1];
                        scope.minutes = d[2];
                        scope.seconds = d[3];
                    }
                }, 1000);

                stopTimer = function () {
                    console.log("Should Stop");
                    $interval.cancel(stop);
                };
            }
        };
    }
]).factory('Util', [
    function () {
        return {
            dhms: function (t) {
                var days, hours, minutes, seconds;
                days = Math.floor(t / 86400);
                t -= days * 86400;
                hours = Math.floor(t / 3600) % 24;
                t -= hours * 3600;
                minutes = Math.floor(t / 60) % 60;
                t -= minutes * 60;
                seconds = t % 60;
                return [days, hours, minutes, seconds];
            }
        };
    }
]);
</code>```

HTML

```<code><div class="col-xs-12" ng-repeat="event in events">
    <countdown date="{{ event.event_date }}"></countdown>
</div>
</code>```

TEMPLATE

```<code><div class='time_division_container'>
    <div class='digits_container'>{{ days }}</div>
    <div class='label_container'>DAYS</div>
</div>
<div class='time_division_container'>
    <div class='digits_container'>{{ hours }}</div>
    <div class='label_container'>HOURS</div>
</div>
<div class='time_division_container'>
    <div class='digits_container'>{{ minutes }}</div>
    <div class='label_container'>MINUTES</div>
</div>
<div class='time_division_container'>
    <div class='digits_container'>{{ seconds }}</div>
    <div class='label_container'>SECONDS</div>
</div>
</code>```

This works fine at first if the countdown is only 1. But when I add multiple event_date in the event object the

```<code>$interval.cancel(stop);
</code>```

seems not working.

For example if I have these event dates

```<code>var events = {
    {"event_date" : "2017-11-30 12:00:00"},
    {"event_date" : "2017-11-01 09:00:00"}
};
</code>```

The first date is working fine but the second date which has already passed is not stopping its countdown. If you look at the console log it still displays "Should Stop" multiple times. It should only display once since I made and if statement that calls the "stopTimer" function when the difference of the current time and the event date is 0 or negative.

Please help. Thanks a lot.

答:
You have a scoping problem. stopTimer is being defined as a global variable, and each time the directive instantiates it overwrites the previous definition. So when you call stopTimer from the first directive, it calls the stopTimer defined in the second directive, who's stop variable is pointing to something else. Also, probably a typo in your question, but events should be an array for ng-repeat to work.

If you change:

```<code>  stopTimer = function () {
    console.log("Should Stop");
    $interval.cancel(stop);
  };
</code>```

to

```<code>  var stopTimer = function () {
    console.log("Should Stop");
    $interval.cancel(stop);
  };
</code>```

it works correctly, as stopTimer is now scoped. See the attached plunkr: https://plnkr.co/edit/41DlPAP07iBtmAq3kKbR

Aside, it's useful to enable strict mode to avoid scoping problems like this. See What does "use strict" do in JavaScript, and what is the reasoning behind it?. If strict mode were enabled, you would have seen an error in your console.

Title: How to use directive multiple times

Body:
Basically I have copied this code from another source which is a countdown timer.

Directive

app.directive('countdown', [
    'Util', '$interval', function (Util, $interval) {
        return {
            restrict: 'E',
            scope: {
                date: '@'
            },
            templateUrl: 'countdown_timer.html',
            link: function (scope, element) {
                var future = new Date(scope.date);

                var stop;

                stop = $interval(function () {
                    var diff;
                    diff = Math.floor((future.getTime() - new Date().getTime()) / 1000);

                    if (parseInt(diff) <= 0) {
                        stopTimer();
                        scope.days = 0;
                        scope.hours = 0;
                        scope.minutes = 0;
                        scope.seconds = 0;
                    } else {
                        var d = Util.dhms(diff);
                        scope.days = d[0];
                        scope.hours = d[1];
                        scope.minutes = d[2];
                        scope.seconds = d[3];
                    }
                }, 1000);

                stopTimer = function () {
                    console.log("Should Stop");
                    $interval.cancel(stop);
                };
            }
        };
    }
]).factory('Util', [
    function () {
        return {
            dhms: function (t) {
                var days, hours, minutes, seconds;
                days = Math.floor(t / 86400);
                t -= days * 86400;
                hours = Math.floor(t / 3600) % 24;
                t -= hours * 3600;
                minutes = Math.floor(t / 60) % 60;
                t -= minutes * 60;
                seconds = t % 60;
                return [days, hours, minutes, seconds];
            }
        };
    }
]);

HTML

    <countdown date="{{ event.event_date }}"></countdown>

TEMPLATE

{{ days }}

DAYS

{{ hours }}

HOURS

{{ minutes }}

MINUTES

{{ seconds }}

SECONDS

This works fine at first if the countdown is only 1. But when I add multiple event_date in the event object the

$interval.cancel(stop);

seems not working.

For example if I have these event dates

var events = {
    {"event_date" : "2017-11-30 12:00:00"},
    {"event_date" : "2017-11-01 09:00:00"}
};

The first date is working fine but the second date which has already passed is not stopping its countdown. If you look at the console log it still displays "Should Stop" multiple times. It should only display once since I made and if statement that calls the "stopTimer" function when the difference of the current time and the event date is 0 or negative.

Please help. Thanks a lot.

Body:
You have a scoping problem. stopTimer is being defined as a global variable, and each time the directive instantiates it overwrites the previous definition. So when you call stopTimer from the first directive, it calls the stopTimer defined in the second directive, who's stop variable is pointing to something else. Also, probably a typo in your question, but events should be an array for ng-repeat to work.

If you change:

  stopTimer = function () {
    console.log("Should Stop");
    $interval.cancel(stop);
  };

to

  var stopTimer = function () {
    console.log("Should Stop");
    $interval.cancel(stop);
  };

it works correctly, as stopTimer is now scoped. See the attached plunkr: https://plnkr.co/edit/41DlPAP07iBtmAq3kKbR

Aside, it's useful to enable strict mode to avoid scoping problems like this. See What does "use strict" do in JavaScript, and what is the reasoning behind it?. If strict mode were enabled, you would have seen an error in your console.