Hello together

I'm very new to mobile app development and JS frameworks such as Angular as 
well.
I didn't do much in learning by reading or making tutorials but started 
with Apache Cordova from where I "fell" into Ionic, starting with an 
example project and trying to move forward using trial and error and google 
as my best friend for what I needed ad the moment.
So Ionic led me to Angular.js - and therefore I've not really an idea how 
Angular should be used or what should be done which way. Therefore some 
basic questions from my side:

So, on the "left" side I have my services.js with the data models which 
rely on "localStorage" and are empty first and need an "update" call to 
update localStorage from local array copies.
On the "middle" side i have my app.js which does basic initialisation and 
populates some local storage on first launch (user activation) or 
initialises some stuff if already activated and helds local copies of 
localStorage (some tokens).
On the "right" side I have my views which for example show data from the 
through localStorage initialised models and too can cause changes of data 
in already initialized model through user interaction as for example in the 
following scenario:

In the "new entry" view I've 3 selects which show data from the models with 
ng-repeat. The first one is an organisation selection and the 2nd/3rd ones 
are cat/type which are dependent from the selected org.
So if I change the org, the cats/types models become invalid and need to be 
refreshed from localStorage with the data from the selected org.
I tried calling a function switchOrganisation() in my models on org. change 
but even failed accessing it alltough the model or even the function was 
defined in the scope in the controller.

Then the second "problem": When I change the org, localStorage and 
theoretically the local variables in .run() should be changed too. 1st I 
can do manually on change but 2nd I don't know how to access but it isn't 
that bad since atm I don't need them anymore after activation.
But anyway it is always some kind of inconsistency respectively I have to 
manually take huge care that all the datas are consistent and match to each 
other.
When for example I even change the user, atm 4 models change 
(organisations, types, categories and an entries list). This has to be done 
manually or what I would do atm is like at activation, set the localStorage 
tokens and call $window.location.reload(true);.
Maybe my approach isn't good but for that's too late now anyway.....

Then like in the MVC principle, when changing the model, the view should 
change too (change org -> types/cats selects should be refreshed too). But 
I don't think this will work with ng-repeat...??
I wasn't able to check this since I wasn't able to correctly access the 
switchOrganisation-functions of the types and cats models in the org. 
select's onchange.

About scopes: How for example to access a control from .run() or from a 
model? Or isn't this possible and/or shouldn't be done anyway?
And why does even the following not work:

    <ion-content class="padding">
        <script type="text/javascript">
            function lalala() { //organisations_onChange() {
                //alert(val);
                alert("sdfsdf");
            }
        </script>

            <select onchange="lalala();">
            .....

Thank you very much for any help and advices!

Best regards


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to