Giter Site home page Giter Site logo

Comments (13)

edusperoni avatar edusperoni commented on June 2, 2024 1

it seems like your code on iOS is static, while android has dynamic content. So most likely angular itself is using setAttribute (correctly) on iOS and setProperty on Android (which has no namespace support)

from angular.

edusperoni avatar edusperoni commented on June 2, 2024

Hello!

Can you please enable the NativeScript Angular logs (set Trace.enable() in your polyfills.ts, and enable the NativeScriptDebug.rendererTraceCategory).

You should be seeing this log on the screen:

NativeScriptDebug.rendererLog(`NativeScriptRenderer.setAttribute ${namespace ? namespace + ':' : ''}${el}.${name} = ${value}`);

I suspect this issue comes from the angular side, not our side, so most likely that log will be setting the string value itself instead of evaluating the expression. The NativeScript angular integration doesn't evaluate any expressions, we just apply what angular provides to us via the Renderer2 API

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

Hello @edusperoni , not sure how I have to do it. could you please explain what I have to set in polyfills.ts.
So far I only used Trace by putting the following code into app.module.ts

import { Trace } from '@nativescript/core';
Trace.addCategories(Trace.categories.Style)
Trace.enable();

However, there seems to be no category NativeScriptDebug.rendererTraceCategory

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

@edusperoni, I tried to set
Trace.addCategories(Trace.categories.All)
as I was not able to import NativeScriptDebug

import { NativeScriptDebug } from '@nativescript/angular/lib/trace';
Trace.addCategories(NativeScriptDebug.rendererTraceCategory);
Trace.enable();

and I also tried to set it as string Trace.addCategories('NativeScriptDebug.rendererTraceCategory').

The later does not work and the first one does not result in any output of NativeScriptDebug.rendererLog.

I finally also tried to set
import { Trace } from '@nativescript/core';
Trace.enable();

in src/polyfill.ts, but I do not get any NativeScriptRenderer.setAttribute output either.

Please provide a more detailed description how I can enable it.

from angular.

edusperoni avatar edusperoni commented on June 2, 2024

The NativeScriptDebug is exported as ɵNativeScriptAngularDebug. In any case, you can enable the category 'ns-renderer' instead

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

I now did try both variants in app.module.ts, but I do not see any output

import { Trace } from '@nativescript/core';

import { ɵNativeScriptAngularDebug } from '@nativescript/angular';
Trace.addCategories(ɵNativeScriptAngularDebug.rendererTraceCategory);
Trace.enable();

and Trace.addCategories('ns-renderer');
Trace.enable();

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

ok, got it. Had to go into polyfills.ts

It looks like the expression is evaluated, see attached file line 1404 and 1405

ns-renderer: NativeScriptRenderer.setProperty GridLayout(107).:android:columns = *,10,*
ns-renderer: NativeScriptRenderer.setProperty GridLayout(107).:android:rows = *,10,*,10,*

This looks correct?

It looks awkward to me ":android:"

out.txt

Update: I just compared it against the old NS Angular version 17.2.1 there it looks different

 ns-renderer: NativeScriptRenderer.setProperty GridLayout(107).columns = *,10,*
 ns-renderer: NativeScriptRenderer.setProperty GridLayout(107).rows = *,10,*,10,*

Seems like the android prefix is broken? Should be removed?

from angular.

edusperoni avatar edusperoni commented on June 2, 2024

@cjohn001 is there any calls to setAttribute on the old one? Seems like the new version isn't calling setAttribute with the namespace.

Seems like angular might have changed the way it stets these kinds of properties. I'll take a look later if this is something it makes sense for us to support or not.

In the meantime I highly recommend using a function/getter instead and bind that to the colums/rows, as it'll avoid multiple evaluation calls too (right now your code will process row/columns for both platforms, but only select one of them). Something like:

get rows() {
  if(isAndroid) {
     if(this._tinyScreen....) { ... }
     return '....';
   }
   return '....';
}

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

@edusperoni you mean if I am calling setAttribute? No.

In regards to the android: ios: you do not want to support it anymore? In that case I would have to check my entire code for it. Use it for multiple attributes..

One more question to this regarding efficiency. I think to remember to have red that I also should not call functions from templates when possible as those are to be evaluated for each redraw. I am therefore wondering if the approach you provided is more efficient. Or should I maybe use a signal for it? Seems like those somtimes work and sometimes do not. I observed them not to refresh. However, here refresh is not required as the platform never changes

from angular.

edusperoni avatar edusperoni commented on June 2, 2024

it's not that we don't want to support it anymore, it's that angular is changing how it sets those, so we'd need to work around it. Ever since I wrote the tests for it, dynamic values didn't work properly (while static values like you tried, work, because properties don't have namespaces, while attributes do). I personally don't use that feature for dynamic values because of that, and most of the time it's better to use a getter or function instead.

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

Ok, than I better change my code. Would be good to skip this feature than with a new major release. How about using a signal instead. I think you had answered before I finished updating my question :)

from angular.

cjohn001 avatar cjohn001 commented on June 2, 2024

And maybe a last question to the topic. I am wondering why this stuff works on ios and not on android. I thought the same angular library is used on both platforms. Do you have an idea why this could be?

from angular.

paul-staskiewicz avatar paul-staskiewicz commented on June 2, 2024

It also affects platform-specific css (https://docs.nativescript.org/guide/styling#platform-specific-css) when used with dynamic values.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.