Home Angular model doesn't update after ng-click
Reply: 0

Angular model doesn't update after ng-click

user1852 Published in March 18, 2018, 2:11 am

the ng-repeat model doesn't update after a user clicks submit, it will only show on refresh, i reviewed a similar problem, but i couldn't connect the dots. A user recommended i do a ng-init, but i don't think im doing it right.

with ng-init it shows no data, without ng-init and removing the angular function it shows posts but doesn't update the model after click.

note:the angular brackets are replaced because laravel blade doesn't like it


    <div id="mypost" class="col-md-8 panel-default" ng-init="getPosts()" ng-repeat="post in myposts">
        <div id="eli-style-heading" class="panel-heading"><% post.title %></div>
            <div class="panel-body panel">
                    <p> <% post.body %></p>




// this doens't show posts when i use ng-init
$scope.getPosts = function(){

        $scope.myposts = data.data;


// this shows posts without ng-init but doesn't update when a user adds data

    $scope.myposts = data.data;

Updated Again

network error


public function storePost(Request $request)
    $data = request()->validate([
     'title' => 'required|max:120',
     'body' => 'required|max:1000'

    $data['user_id'] = auth()->user()->id;

    $post = Post::create($data);

    // return redirect('/home')->withMessage('A new post was created.');

    return Response::json(array('success' => true));

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.304267 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO