This question is similar to this one but different enough to make a new thread.
While working on angular 2 animations, I could not figure out how to access the colors variables that are located in [project]\src\theme\variable.scss.
Let's say [project]\src\theme\variable.scss has this on top:
$colors: (
primary: #387ef5,
secondary: #32db64,
...
);
Now in a Ionic 2/Angular 2 Component, in the @Component
annotation, I have something like that:
animations: [
trigger('changeBackgroundColor', [
state('active', style({
backgroundColor: [Some statement to define the active color]
})),
state('inactive', style({
backgroundColor: '#32db64'
})),
transition('* => inactive', animate('800ms ease')),
transition('* => active', animate('800ms ease')),
transition('inactive=> active', animate('800ms ease')),
transition('active=> inactive', animate('800ms ease')),
]),
]
Now I have tried the following to set the backgroundColor in the field [Some statement to define color active]
:
'#387ef5'
=> THIS WORKS;'($colors,primary)'
=> DOES NOT WORK'color($colors,primary)'
=>DOES NOT WORK'primary'
=> DOES NOT WORK
Everytime it does not work, it throws error: Failed to execute 'animate' on 'Element': Partial keyframes are not supported.
;
I am surprised I could not access the variables in "variable.scss", because the statement to define the backgroundColor
is embedded within a style({})
statement. And I imagined that whithin style({})
regular CSS could be used, contrary to the other topic I refer to, where the aim is to access the CSS values in TypeScript.
Has anyone an answer, or can enlighten me regarding this?