Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AngularJS
16-11-2015, 10:44 PM
Post: #1
AngularJS
Pozdrav svima ,

Poceo sam da ucim AngularJS i za par sati savladao sam model-e ,filter-e , ng , scope , controller (uz to normalno i controller as ) i jos mnogo toga i kad je dosao red na Routing totalno sam zakocio , evo 2 dana pokusavam da naucim ali ne ide , da li neko zna neki dobar klip u vezi "routing" ili jos bolje neku knjigu koja sve lijepo i postupno objesnjava.... Unaprijed hvala ..
Send this user an email Find all posts by this user
Quote this message in a reply Thank you
28-10-2016, 02:21 PM
Post: #2
RE: AngularJS
Pozdrav, znam da je prošlo skoro godinu dana, ali kako nema odgovora, pokušati ću odgovoriti, pa možda nekome i pomogne. Uglavnom, "routing" je princip, nazovimo tako, prebacivanja između VIEW-a u angularjs app. Preporucam koristenje ui-rotera, zato što je više zastupljen te nudi dodatne (naprednije) opcije.
Znaci prvo je potrebno downloadati library, inace bolja praksa je koristiti bower za instaliranje librarya. ZAtim treba u module ubaciti dependecy
Code:
var app= angular.module('app', [
        'ui.router',          
]);

nakon toga treba naravno dodati <script> tagove. I složiti config da bi to sve funkcioniralo.
Evo jedan jednostavni:
Code:
app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider',
    function ($stateProvider, $urlRouterProvider, $locationProvider) {

        $urlRouterProvider.otherwise(function ($injector, $location) {
            
            var $state = $injector.get("$state");
            $state.go("login");
        });

        $stateProvider

                .state('login', {
                    url: '/',
                    templateUrl: 'authhh/views/login.html',
                    controller: 'loginController'
                })
                
                .state('signup', {
                    url: '/signup',
                    templateUrl: 'authhh/views/signup.html',
                    controller: 'signupController as registration'
                })
                
                .state('resset-password', {
                    url: '/resset-password',
                    templateUrl: 'authhh/views/ressetPassword.html',
                    controller: 'resetPasswordCtrl'
                })

                $locationProvider.html5Mode(true);

    }]);

I kada slažemo u html-u view, "linkove" pozivamo sa "ui-sref" kao npr:
Code:
<a ng-hide="authentication.isAuth" ui-sref="login">{{'LOG_IN'| translate}} |</a>
<a ng-hide="authentication.isAuth" ui-sref="signup">{{'SIGN_UP'| translate}}</a>
Send this user an email Find all posts by this user
Quote this message in a reply Thank you
Thanks given by (2): joker123, Igor Tomić
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)